Jump to content

I want to create an automation script for searching craigslist ads


phatzilla
 Share

Recommended Posts

Use

_IELinkClickByText($oIE, "next 100 postings")

_IELoadWait($oIE)

and then start over...

Dale

p.s. Check the return status of _IELinkClickByText to see if it found a link for the next 100 or not...

Also, as mentioned earlier, _IECreate has a parameter for invisible. _IEQuit kills the window

Check out the new soucre and see what you think .....

and ill have to use the help file to make it invis then

[center][/center]

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Ok heres the new source.....

It only does two pages and it fixes a minor error that every 20 mins didnt delete results....

So check it out it uses dalehohm's method to get the first 200 items!

#include <IE.au3>
#include <Array.au3>
While 1
FileDelete( @ScriptDir & "\Results.htm" )
FileDelete( @scriptdir & "\Results.ini" )


$oIE = _IECreate("http://dayton.craigslist.org/sss/") ;not sure how to hide  ;<---CAHNGE TO YOUR URL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

$oPs = _IETagNameGetCollection($oIE, "p")
$cntPs = @extended

Global $aLinkInfo[200][3]                ;<---ALLOWS FOR 95 PAGES (9500 ITEMS) !!!!!!!!!!!!!!!! This is Pages * 100

$aLinkInfo[0][0] = "Index"
$aLinkInfo[0][1] = "Link Text"
$aLinkInfo[0][2] = "href"

$cnt = 1
For $oP in $oPs
    $oLink = _IETagNameGetCollection($oP, "a", 0)
    $aLinkInfo[$cnt][0] = $cnt - 1
    $aLinkInfo[$cnt][1] = $oLink.innerText
    $aLinkInfo[$cnt][2] = $oLink.href
    $cnt +=1
Next

_IELinkClickByText($oIE, "next 100 postings")  ;moving on to page 2
_IELoadWait($oIE)

$oPs = _IETagNameGetCollection($oIE, "p")
For $oP in $oPs
    $oLink = _IETagNameGetCollection($oP, "a", 0)
    $aLinkInfo[$cnt][0] = $cnt - 1
    $aLinkInfo[$cnt][1] = $oLink.innerText
    $aLinkInfo[$cnt][2] = $oLink.href
    $cnt +=1
Next





$y = 0
$terms = IniReadSection( @SCRIPTDIR & "\Settings.ini", "Terms" )  ;compare and find results
For $i = 1 to $terms[0][0] step 1;to compare for every term
For $x = 1 to $cnt-1 step 1;compare that term to every result
If StringInStr( $aLinkInfo[$x][1], $Terms[$i][1] ) <> 0 Then
    $y=$y+1
    IniWrite( @ScriptDir & "\Results.ini", "Results", $alinkinfo[$x][1], $alinkinfo[$x][2] )
Endif
Next    
Next


$results = IniReadSection( @SCRIPTDIR & "\Results.ini", "Results")
If $y <>0 Then
$file = FileOpen( @ScriptDir & "\Results.htm", 9 )   ;write page header
FileWriteLine( $file, '<h2>AutoIT Search Companion for Craigs List Found <b>' & $y & '</b> results that matched your search criteria!</h2>' & @CRLF )   
For $u = 1 to $results[0][0] step 1     
FileWriteLine( $file, '<p><a href="' & $results[$u][1] & '">' & $results[$u][0] & '</a></p>' & @CRLF ) ;write links and data
Next
FileClose($File)
TrayTip( "Craigs List Results", "Search Found " & $y & " items!", 5000 );results
Sleep(5000)
TrayTip("","",0)
Else
FileClose($File)
TrayTip( "Craigs List Results", "Inconclusive Search (0 Results)", 5000 );for no results
Sleep(5000)
TrayTip("","",0)
EndIf
;ShellExecute( @Scriptdir & "\Smpt.exe", @Scriptdir & "\Results.htm" ) ;UES THIS LINE TO USE SMPT
Sleep((1000*60)*20);20 min Sleep
Wend;start all over

Any Luck on the SMPT ??? Maybe when we finish we should put this on the Example Scripts...

[center][/center]

Link to comment
Share on other sites

$site= "http://toronto.craigslist.org/ele/"

$oIE = _IECreate($site,0,0,1,-1)

Now that works, it would be nice if you can altar the ini under a new section [site] for example and then input any site you want and the program would navagate to that site.

For example:

$site = IniReadSection( @SCRIPTDIR & "\Settings.ini", "Site" )

$oIE = _IECreate($site,0,0,1,-1)

My INI :

[site]

http://toronto.craigslist.org/ele/

For some reason that code doesnt work

Edit : Nevermind, i got it!

$site = IniRead( @SCRIPTDIR & "\Settings.ini", "Site" , "Site", "default" )

[site]

Site=http://toronto.craigslist.org/ele/

Edited by phatzilla
Link to comment
Share on other sites

$site= "http://toronto.craigslist.org/ele/"

$oIE = _IECreate($site,0,0,1,-1)

Now that works, it would be nice if you can altar the ini under a new section [site] for example and then input any site you want and the program would navagate to that site.

For example:

$site = IniReadSection( @SCRIPTDIR & "\Settings.ini", "Site" )

$oIE = _IECreate($site,0,0,1,-1)

My INI :

[site]

http://toronto.craigslist.org/ele/

For some reason that code doesnt work

Thats becuz inireadsection returns a 2 dim array u have to use this

$site = IniRead( @SCRIPTDIR & "\Settings.ini", "Site", "Site", "About:blank" )
$oIE = _IECreate($site,0,0,1,-1)

That way it will read the ini like so:

[site]

site=http://toronto.craigslist.org/ele/

[term]

1=jeep

2=computer

......

and if you dont put the value in the ini it will defualt at about:Blank

[center][/center]

Link to comment
Share on other sites

  • 4 weeks later...

Well good night guys ill be back on tommorrow about 3:45

I've been modifying this program to get it right for me. Does anyone know how to include the location (Henderson/Las Vegas, below) that displays on Craig's list after the Link and the orange "pic" to indicate there is a picture? As in:

1994 Suzuki Katana GSX600F - $1999 (Henderson/Las Vegas) pic

I'd like to capture and display those items on the "Results" html.

Freedom1

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...