I would like to build a dictionary out of iterating over two different for loops:
My code is:
from bs4 import BeautifulSoup
from xgoogle.search import GoogleSearch, SearchError
try:
gs = GoogleSearch("search query")
gs.results_per_page = 50
results = gs.get_results()
for res in results:
print res.title.encode("utf8")
print res.url.encode("utf8")
print
except SearchError, e:
print "Search failed: %s" % e
This code outputs a title and a url for each page found
I would like to get the following output
{title1:url1, title50,url50}
What would be a succint way to resolve this?
Thanks!