Sign in to follow this  
Followers 0
ATR

For...Next problem

1 post in this topic

#1 ·  Posted (edited)

I want recover an area of the web. And if the number of results are on multiple pages, it doesn't work :graduated:

#include <IE.au3>

#Include <String.au3>

#Include <Array.au3>

RechercheInternet("affaires-sanitaires-sociales-services-publics", "75", "paris")

Func RechercheInternet($Rubrique_internet, $CodePostal, $Ville_internet)

ConsoleWrite("http://www.pagesjaunes.fr/annuaire/" & $Ville_internet & "-" & $CodePostal & "/" & $Rubrique_internet & " - ")

$IE = _IECreate("http://www.pagesjaunes.fr/annuaire/" & $Ville_internet & "-" & $CodePostal & "/" & $Rubrique_internet, 0, 1) ; 3e argument : 0 = non visible - 1 = visible

If @error Then

MsgBox(16, "Erreur", "La page internet n'a pu être créée correctement.")

Exit

EndIf

_IELoadWait($IE)

$oInputs_h1 = _IETagNameGetCollection ($IE, "div")

For $oInput_h1 In $oInputs_h1

If StringInStr($oInput_h1.classname, "reformulationZone") Then

$Remplacement_espaces = StringRegExpReplace($oInput_h1.outerhtml, '[\h]', '')

$Nombre_resultats = StringRegExp($Remplacement_espaces, '(?s)</h1>.*?;)\d*).*?réponse', 1)

If @error = 0 Then

If $Nombre_resultats[0] <> "#null" Then

$Nombre_pages = Ceiling($Nombre_resultats[0] / 15)

ConsoleWrite($Nombre_pages & " page(s)" & @TAB & $Nombre_resultats[0] & " résultat(s)" & @CRLF)

$n = 2

For $i = 1 To $Nombre_pages

If $i > 1 Then

_IENavigate($IE, "http://www.pagesjaunes.fr/trouverlesprofessionnels/changerPage.do?numPage=" & $i)

Sleep(1000)

EndIf

$oInputs = _IETagNameGetCollection ($IE, "li")

For $oInput In $oInputs

If StringInStr($oInput.classname, "visitCard withVisual sc") Then

$Remplacement_espaces = StringRegExpReplace($oInput.outerhtml, '[\h]', '')

$Nom_societe = StringRegExp($oInput.outerhtml, '(?s)titleMain">\s*.*?">(.*?)</', 1)

If @error = 0 Then

If $Nom_societe[0] <> "#null" Then

ConsoleWrite("Nom de la societe : " & $Nom_societe[0] & @CRLF)

EndIf

EndIf

$n += 1

EndIf

Next

Next

;~ _IEQuit($IE)

EndIf

EndIf

EndIf

Next

EndFunc

Edited by ATR

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0