在URL中包含"alpha"的链接上有许多链接(hrefs),我想从20个不同的页面收集这些链接并粘贴到通用URL的末尾(第二行最后一行).href可以在一个表中找到,该类对于td是mys-elastic mys-left,而a显然是包含href属性的元素.任何帮助都会非常感激,因为我已经在这里工作了大约一个星期.
for i in range(1, 11):
# The HTML Scraper for the 20 pages that list all the exhibitors
url = 'http://ahr13.mapyourshow.com/5_0/exhibitor_results.cfm?alpha=%40&type=alpha&page=' + str(i) + '#GotoResults'
print url
list_html = scraperwiki.scrape(url)
root = lxml.html.fromstring(list_html)
href_element = root.cssselect('td.mys-elastic mys-left a')
for element in href_element:
# Convert HTMl to lxml Object
href = href_element.get('href')
print href
page_html = scraperwiki.scrape('http://ahr13.mapyourshow.com' + href)
print page_html
Run Code Online (Sandbox Code Playgroud)