IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Shell et commandes GNU Discussion :

Automatisation de publication d'annonces


Sujet :

Shell et commandes GNU

  1. #1
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut Automatisation de publication d'annonces
    Bonjour,

    Je souhaite créer un script pour automatiser la publication d'annonces sur le site LeBonCoin. J'ai un compte sur ce site, j'aimerais m'y connecter, et déposer l'annonce en ligne.
    J'ai cru comprendre qu'avec curl, on pouvait le faire?

    Quelqu'un peut m'aider?

    Merci d'avance.

  2. #2
    Expert confirmé
    Homme Profil pro
    Développeur informatique en retraite
    Inscrit en
    Avril 2008
    Messages
    2 101
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique en retraite

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 101
    Points : 5 849
    Points
    5 849
    Par défaut
    Citation Envoyé par chris_wafer Voir le message
    Quelqu'un peut m'aider?
    Il manque l'information principale: combien payes-tu la prestation?

  3. #3
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Je ne paye personne, je veux arriver tout seul à le faire, mais avec votre aide.

  4. #4
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    26 859
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 26 859
    Points : 218 580
    Points
    218 580
    Billets dans le blog
    120
    Par défaut
    Bonjour,

    Dans le navigateur, il faut analyser les entête HTTP + les URL utilisées (cela se fait grâce à un plugin).
    Ensuite, il faut les reproduire avec CURL.

    Sinon, vous pourriez jeter un coup d'oeil sur le projet WEBOOB, il vous permettra peut être d'y arriver.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  5. #5
    Expert confirmé
    Homme Profil pro
    Développeur informatique en retraite
    Inscrit en
    Avril 2008
    Messages
    2 101
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique en retraite

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 101
    Points : 5 849
    Points
    5 849
    Par défaut
    Citation Envoyé par chris_wafer Voir le message
    Je ne paye personne, je veux arriver tout seul à le faire, mais avec votre aide.
    Alors, dis-nous ce que tu as essayé, ce qui marche et ce qui ne marche pas...

    Citation Envoyé par chris_wafer Voir le message
    J'ai cru comprendre qu'avec curl, on pouvait le faire?

    Quelqu'un peut m'aider?
    Essaye la commande suivante:


  6. #6
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Oui, j'ai essayé, mais je n'y comprends pas grand chose.
    Quelqu'un peut m'aiguiller?

    Merci.

  7. #7
    Expert confirmé
    Homme Profil pro
    Développeur informatique en retraite
    Inscrit en
    Avril 2008
    Messages
    2 101
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique en retraite

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 101
    Points : 5 849
    Points
    5 849
    Par défaut
    Citation Envoyé par chris_wafer Voir le message
    Quelqu'un peut m'aiguiller?
    On ne peut pas t'aider à partir de rien.

    À la rigueur, on peut faire le travail à ta place, mais ça dépend de la rémunération proposée.

    Citation Envoyé par chris_wafer Voir le message
    Oui, j'ai essayé,
    Peux-tu nous dire ce que tu as essayé?

    mais je n'y comprends pas grand chose.
    Peut-être lire un tutoriel?

  8. #8
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Je viens d'essayer cela :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    curl 'https://compteperso.leboncoin.fr/store/verify_login/0' -H 'Host: compteperso.leboncoin.fr' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.leboncoin.fr/' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' --data 'st_username=MONMAIL%40gmail.com&st_passwd=MONPASS'
    Comment savoir si ça a bien marché?

    Merci.

  9. #9
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    26 859
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 26 859
    Points : 218 580
    Points
    218 580
    Billets dans le blog
    120
    Par défaut
    En testant et en essayant de voir la réponse renvoyée par le site.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  10. #10
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Bonjour,

    Je me suis intéressé à "weboob", il est installé, le module leboncoin est installé, mais comment l'utiliser?

    Merci.

  11. #11
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    La commande CURL ne retourne rien. Il faut activer quelquechose?

  12. #12
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    J'ai bien progressé, ça y est je maitrise, j'ai réussi à supprimer une annonce.
    Par contre, pour en poster une, j'ai le code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    curl --silent \
    -b /tmp/cookies \
    -c /tmp/cookies \
    'https://www.leboncoin.fr/ai/verify/0' \
    -H 'Host: www.leboncoin.fr' \
    -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0' \
    -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
    -H 'Accept-Language: en-US,en;q=0.5' \
    --compressed \
    -H 'Referer: https://www.leboncoin.fr/ai/form/0' \
    -H 'Connection: keep-alive' \
    -H 'Upgrade-Insecure-Requests: 1' \
    -H 'Content-Type: multipart/form-data; boundary=---------------------------1855287202331431558583870453' \
    --data-binary $'-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="check_type_diff"\r\n\r\n0\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="category"\r\n\r\n35\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="company_ad"\r\n\r\n0\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="type"\r\n\r\ns\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="subject"\r\n\r\nVend places concert Muse\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="brand"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="regdate"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="mileage"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="fuel"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="gearbox"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="cubic_capacity"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="real_estate_type"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="furnished"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="square"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="rooms"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="energy_rate"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="ges"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="capacity"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="swimming_pool"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="bedrooms"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="clothing_type"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="clothing_st"\r\n\r\n0\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="shoe_type"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="shoe_size"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="baby_age"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="jobcontract"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="jobfield"\r\n\r\n0\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="jobduty"\r\n\r\n0\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="jobexp"\r\n\r\n0\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="jobstudy"\r\n\r\n0\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="jobtime"\r\n\r\n1\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="animal_offer_nature"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="animal_race"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="animal_age"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="animal_litter"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="animal_litter_number"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="animal_identification"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="datepicker_begin_date"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="availability_begin_date"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="datepicker_end_date"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="availability_end_date"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="availability_price"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="price_min"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="price_max"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="body"\r\n\r\nJe vends des places pour le concert. A venir chercher sur place.\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="custom_ref"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="price"\r\n\r\n45\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="charges_included"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="fai_included"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image0"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image1"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image2"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image3"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image4"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image5"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image6"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image7"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image8"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="image9"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="location_p"\r\n\r\nCenon\xa033150\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="zipcode"\r\n\r\n33150\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="city"\r\n\r\nCenon\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="region"\r\n\r\n2\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="dpt_code"\r\n\r\n33\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="address"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="meeting_point_id"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="accept_localisation"\r\n\r\non\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="latitude"\r\n\r\n44.8583\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="longitude"\r\n\r\n-0.53053\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="geo_source"\r\n\r\ncity\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="geo_provider"\r\n\r\nlbc\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="adreply_type"\r\n\r\n1\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="adreply_redirect"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="name"\r\n\r\nmon_pseudo\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="siren"\r\n\r\n\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="email"\r\n\r\ntutu@toto.com\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="phone"\r\n\r\n0606060606\r\n-----------------------------1855287202331431558583870453\r\n\r\nContent-Disposition: form-data; name="no_salesmen"\r\n\r\n1\r\n---------------------------1855287202331431558583870453--\r\n'
    D'où vient ce numéro 1855287202331431558583870453 dans binary ?

  13. #13
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Quelqu'un peut m'aider?
    Merci.

  14. #14
    Expert confirmé
    Homme Profil pro
    Développeur informatique en retraite
    Inscrit en
    Avril 2008
    Messages
    2 101
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique en retraite

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 101
    Points : 5 849
    Points
    5 849
    Par défaut
    Je n'y connais pas grand-chose, mais j'espère que ce que j'écris est correct et te donnera des pistes pour chercher sur internet!

    Les données transmises semblent être du type "multipart", c'est-à-dire qu'elles contiennent plusieurs morceaux (comme un mail qui contient le texte proprement dit et diverses pièces jointes). Et ces morceaux doivent être séparés par un... séparateur, afin que le récepteur des données sache comment découper le message en morceaux cohérents. C'est à ça que sert le "boundary": c'est le séparateur de morceaux.
    Ici, sa valeur est "boundary=---------------------------1855287202331431558583870453", comme indiqué dans le descripteur du contenu des données (en espérant que les données ne contiennent pas accidentellement comme par hasard précisément cette chaine de caractères!). En revanche, je ne sais pas qui décide d'utiliser cette valeur plutôt qu'une autre.

    J'espère que cette piste te permettra d'avancer...

  15. #15
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Merci.

    Quelqu'un pourrait m'aider en privé avec ce module?
    Merci.

  16. #16
    Responsable Systèmes


    Homme Profil pro
    Gestion de parcs informatique
    Inscrit en
    Août 2011
    Messages
    17 440
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Gestion de parcs informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Août 2011
    Messages : 17 440
    Points : 43 082
    Points
    43 082
    Par défaut
    L’intérêt du forum est que l'aide apporté soit publique, ce qui permettra à d'autres utilisateurs ayant le même problème d'avoir la solution.
    Ma page sur developpez.com : http://chrtophe.developpez.com/ (avec mes articles)
    Mon article sur le P2V, mon article sur le cloud
    Consultez nos FAQ : Windows, Linux, Virtualisation

  17. #17
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 882
    Points
    7 882
    Par défaut
    Citation Envoyé par chris_wafer Voir le message
    D'où vient ce numéro 1855287202331431558583870453 dans binary ?
    C'est une chaîne de caractères arbitraire. Tu peux mettre ce que tu veux en respectant les contraintes suivantes :
    • doit commencer par deux tirets (--)
    • doit contenir entre 1 et 70 caractères ASCII 7 bit
    • ne doit pas apparaître ailleurs dans la requête
    • la dernière occurrence doit être suivie par deux tirets
    ɹǝsn *sıɹɐlos*

  18. #18
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Je progresse, je progresse, je suis arrivé à me logguer!!!

    Mais quand je veux poster une nouvelle annonce avec MECHANISE, il me répond : "301 Moved Permanently".

    Quelqu'un peut me dire où il y a on erreur, car je patoge là... Merci.

    Voici mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
     
    #!/usr/bin/perl
     
    use strict; use warnings;
    use WWW::Mechanize;
    use HTML::Tree;
    use Time::HiRes qw(gettimeofday);
    use IO::Handle;
     
    #-----------------------------------------------------
    my $lLogin = 'MonMail';
    my $lPass = 'MonPass';
    my $lAlias = 'MonAlias';
    my $lPhone = 'MonPhone';
    #-----------------------------------------------------
     
    my $url = "";
    my $return = "";
    my $fichier = "";
    my $bot = WWW::Mechanize->new(
      agent => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0",
      timeout     => 3,
      autocheck   => 1,       # check success of each query
      stack_depth => 0,       # no keeping history
      keep_alive  => 50,      # connection pool
    );
    $bot->stack_depth(0);
     
    open my $debugfile, '>traffic.txt';
    $debugfile->autoflush(1);
     
    $bot->add_handler( request_send => sub {
        my $cur_time = gettimeofday();
        my $req = shift;
        print $debugfile "\n$cur_time === BEGIN HTTP REQUEST ===\n";
        print $debugfile $req->dump();
        print $debugfile "\n$cur_time ===   END HTTP REQUEST ===\n";
        return
      }
    );
    $bot->add_handler( response_header => sub {
        my $cur_time = gettimeofday();
        my $res = shift;
        print $debugfile "\n$cur_time === GOT RESPONSE HDRS ===\n";
        print $debugfile $res->dump();
        return
      }
    );
    $bot->add_handler( response_data => sub {
        my $cur_time = gettimeofday();
        my $res = shift;
        my $content_length = length($res->content);
        print $debugfile "$cur_time === Got response data chunk resp size = $content_length ===\n";
        return
      }
    );
    $bot->add_handler( response_done => sub {
        my $cur_time = gettimeofday();
        my $res = shift;
        print $debugfile "\n$cur_time === BEGIN HTTP RESPONSE ===\n";
        print $debugfile $res->dump();
        print $debugfile "\n===   END HTTP RESPONSE ===\n";
        return
      }
    );
     
    unlink 'cookies.txt';
     
    $bot->cookie_jar(
            HTTP::Cookies->new(
                file           => "cookies.txt",
                autosave       => 1,
                ignore_discard => 1,
            )
    );
     
     
    sub AjouterAnnonces()
    {
    	$url = "https://compteperso.leboncoin.fr/store/verify_login";
    	$bot->get($url);
     
    	$return=$bot->form_name('loginform');
    	$return=$bot->field( st_username => $lLogin );
    	$return=$bot->field( st_passwd => $lPass );
    	$return=$bot->submit();
     
    	$url = "https://compteperso.leboncoin.fr/store/verify_login";
    	$bot->get($url);
     
    	$url = "https://www.leboncoin.fr/ai?ca=12_s";
    	$return=$bot->get($url);
     
        # ===================================================================
        # > Débeugage
        # ===================================================================
    	$fichier="MaSortie01.html";
        print "01\n";
    	print "REPONSE (is_success) : ", $bot->response->is_success, "\n";
    	print "REPONSE (status_line) : ", $bot->response->status_line, "\n";
    	print "REPONSE (error_as_HTML) : ", $bot->response->error_as_HTML, "\n";
    	open(MON_FICHIER, ">$fichier") || die "Erreur E/S:$!\n";
    	print MON_FICHIER $bot->content;
        close(MON_FICHIER);
        # ===================================================================
     
    	my $id_annonce=$return->base;
    	$id_annonce =~ s/\?.*$//;
    	$id_annonce =~ s/^.*\///;
     
    	$url="https://www.leboncoin.fr/ai/verify/$id_annonce";
    	$return = $bot->post(
    	  		$url,
    	  		[ 'check_type_diff' => '0',
    	    		'category' => '35',
    	    		'company_ad' => '0',
    	    		'type' => '5',
    	    		'subject' => 'Places concert Muse',
    	    		'brand' => '',
    				'regdate' => '',
    				'mileage' => '',
    				'fuel' => '',
    				'gearbox' => '',
    				'cubic_capacity' => '',
    				'real_estate_type' => '',
    				'furnished' => '',
    				'square' => '',
    				'rooms' => '',
    				'energy_rate' => '',
    				'ges' => '',
    				'capacity' => '',
    				'swimming_pool' => '',
    				'bedrooms' => '',
    				'clothing_type' => '',
    				'clothing_st' => '',
    				'shoe_type' => '',
    				'shoe_size' => '',
    				'baby_age' => '',
    				'jobcontract' => '',
    				'jobfield' => '0',
    				'jobduty' => '0',
    				'jobexp' => '0',
    				'jobstudy' => '0',
    				'jobtime' => '1',
    				'animal_offer_nature' => '',
    				'animal_race' => '',
    				'animal_age' => '',
    				'animal_litter' => '',
    				'animal_litter_number' => '',
    				'animal_identification' => '',
    				'datepicker_begin_date' => '',
    				'availability_begin_date' => '',
    				'datepicker_end_date' => '',
    				'availability_end_date' => '',
    				'availability_price' => '',
    				'price_min' => '',
    				'price_max' => '',
    				'body' => 'Vend places concert Muse. A Bordeaux.',
    				'custom_ref' => '',
    				'price' => '90',
    				'charges_included' => '',
    				'fai_included' => '',
    				'image0' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image1' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image2' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image3' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image4' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image5' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image6' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image7' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image7' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image8' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'image9' => [
    				    undef,   # yes, undef!
    				    '', #filename
    				    'Content_Type' => 'application/octet-stream',
    				    'Content' => ''
    				],
    				'location_p' => 'Bordeaux 33000',
    				'zipcode' => '33000',
    				'city' => 'Bordeaux',
    				'region' => '2',
    				'dpt_code' => '',
    				'location_p' => '33',
    				'address' => '',
    				'meeting_point_id' => '',
    				'accept_localisation' => 'on',
    				'latitude' => '44.83885',
    				'longitude' => '-0.58115',
    				'geo_source' => 'city',
    				'geo_provider' => 'lbc',
    				'adreply_type' => '1',
    				'adreply_redirect' => '',
    				'name' => "$lAlias",
    				'email' => "$lLogin",
    				'phone' => "$lPhone",
    				'phone_hidden' => '1',
    				'no_salesmen' => '1'
     
    	  		],
    	  	'Content_Type' => 'form-data'
    	  	);
     
        # ===================================================================
        # > Débeugage
        # ===================================================================
    	$fichier="MaSortie02.html";
        print "02\n";
    	print "REPONSE (is_success) : ", $bot->response->is_success, "\n";
    	print "REPONSE (status_line) : ", $bot->response->status_line, "\n";
    	print "REPONSE (error_as_HTML) : ", $bot->response->error_as_HTML, "\n";
    	open(MON_FICHIER, ">$fichier") || die "Erreur E/S:$!\n";
    	print MON_FICHIER $bot->content;
        close(MON_FICHIER);
        # ===================================================================
     
    	$url="https://www2.leboncoin.fr/ai/preview/$id_annonce";
    	$return = $bot->get($url);
     
        # ===================================================================
        # > Débeugage
        # ===================================================================
    	$fichier="MaSortie03.html";
        print "03\n";
    	print "REPONSE (is_success) : ", $bot->response->is_success, "\n";
    	print "REPONSE (status_line) : ", $bot->response->status_line, "\n";
    	print "REPONSE (error_as_HTML) : ", $bot->response->error_as_HTML, "\n";
    	open(MON_FICHIER, ">$fichier") || die "Erreur E/S:$!\n";
    	print MON_FICHIER $bot->content;
        close(MON_FICHIER);    
        # ===================================================================
     
    	$url="https://www2.leboncoin.fr/ai/create/$id_annonce";
    	$return = $bot->post(
    	  		$url,
    	  		[ 'category' => '33',
    	  		  'city' => 'Bordeaux',
    	  		  'accept_rule' => '1',
    	  		  'create' => 'Valider mon annonce',
    	  		  'create2' => 'Valider',
    	  		  'category' => '35',
    	  		  'category' => '35',
    	  		  'category' => '35'
     
    	  		],
    	  	'Content_Type' => 'form-data'
    	  	);
     
        # ===================================================================
        # > Débeugage
        # ===================================================================
    	$fichier="MaSortie04.html";
        print "04\n";
    	print "REPONSE (is_success) : ", $bot->response->is_success, "\n";
    	print "REPONSE (status_line) : ", $bot->response->status_line, "\n";
    	print "REPONSE (error_as_HTML) : ", $bot->response->error_as_HTML, "\n";
    	open(MON_FICHIER, ">$fichier") || die "Erreur E/S:$!\n";
    	print MON_FICHIER $bot->content;
        close(MON_FICHIER);    
        # ===================================================================
     
    	$url="https://www2.leboncoin.fr/ai/confirm_no_pay/$id_annonce";
    	$return = $bot->get($url);
     
        # ===================================================================
        # > Débeugage
        # ===================================================================
    	$fichier="MaSortie05.html";
        print "05\n";	
        print "REPONSE (is_success) : ", $bot->response->is_success, "\n";
    	print "REPONSE (status_line) : ", $bot->response->status_line, "\n";
    	print "REPONSE (error_as_HTML) : ", $bot->response->error_as_HTML, "\n";
    	open(MON_FICHIER, ">$fichier") || die "Erreur E/S:$!\n";
    	print MON_FICHIER $bot->content;
        close(MON_FICHIER);    
        # ===================================================================
     
    }
     
    AjouterAnnonces();

  19. #19
    Modérateur
    Avatar de jlliagre
    Homme Profil pro
    Ingénieur support avancé & développement
    Inscrit en
    Juin 2007
    Messages
    2 695
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur support avancé & développement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 695
    Points : 7 882
    Points
    7 882
    Par défaut
    Il n'y a peut-être pas d'erreur.

    Pourquoi penses-tu qu'il y en a une ?
    ɹǝsn *sıɹɐlos*

  20. #20
    Membre à l'essai
    Inscrit en
    Août 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 94
    Points : 21
    Points
    21
    Par défaut
    Quand je fais un get sur la page, les champs ne sont pas remplis.

    Quelqu'un aurait une idée ? Car je sais pas comment debugger là ?

    Merci d'avance pour votre aide.

    Je sens que je suis pas loin...

Discussions similaires

  1. [2008] Automatiser la publication de rapports dans SSRS.
    Par cleml12 dans le forum SSRS
    Réponses: 0
    Dernier message: 22/11/2011, 11h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo