linkGrabber Testing

"""linkGrabber Testing.""" from linkGrabber import Links search = raw_input("What Brand to Search: ") pages = int(raw_input("How Many Pages?: ")) Results = [] for y in range(pages): links = Links("http://ios.25pp.com/search/0_0_0_0_" + str(y) + "/" + search) apps = links.find("a", href=True, duplicates=False) for x in range(len(apps)): TempDict = {} app = apps[x] if 'target' in app.keys() and 'title' in app.keys(): TempDict['title'] = app['title'] TempDict['appurl'] = app['href'] Results.append(TempDict) for x in Results: print (x) print len(Results)

1 Response

```

from linkGrabber import Links
import csvmodule as c
import ToolBox
import json

search = raw_input("ENTER SEARCH TERM: ").replace(" ",'%20')

links = Links(" http://ios.25pp.com/search/" + search)
apps = links.find("a", href=True, duplicates=False)

Results = []
for x in range(len(apps)):
app = apps[x]
if 'target' in app.keys() and 'title' in app.keys():
TempDict = {}
TempDict['title'] = app['title']#.encode("UTF-8",'ignore')
TempDict['appurl'] = app['href']#.encode("UTF-8",'ignore')
Results.append(TempDict)

print Results

j = open("25ppJSON.txt",'w')
js = json.dumps(Results)
j.write(js)
#c.WriteCSV("25pp",Results)
```

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.