Im trying to pull just the keywords from an xml output like shown on:
http://clients1.google.com/complete/search?hl=en&output=toolbar&q=test+a
I have tried putting together the below but i don't seem to get any errors or any output. Any ideas?
import urllib2 as ur
import re
f = ur.urlopen(u'http://clients1.google.com/complete/search?hl=en&output=toolbar&q=test+a')
res = f.readlines()
for d in res:
data = re.findall('<CompleteSuggestion><\/CompleteSuggestion>',d)
for i in data:
print i
file = open("keywords.txt", "a")
file.write(i + '\n')
file.close()
I am trying to,
- Fetch the xml from url given
- Store list of keywords from XML file, parsed using regex
Thanks,
Also. try adding r before the regex string, e.g r'