【发布时间】:2015-07-31 22:15:15
【问题描述】:
所以我编写了以下程序来从这个搜索结果页面https://www.ohiobar.org/Pages/Find-a-Lawyer.aspx?sFN=&sLN=&sPA=&sCI=&sST=OH&sZC=获取所有配置文件 URL
大约有 18,400 多个链接要提取。
但是,当我运行代码时,它不会超出 URL# 1623 并且它会停止而没有给出任何错误或任何东西。
这是我的代码
from bs4 import BeautifulSoup
import requests
url = 'https://www.ohiobar.org/Pages/Find-a-Lawyer.aspx?sFN=&sLN=&sPA=&sCI=&sST=OH&sZC='
with requests.Session() as session:
session.headers = {'User-Agent': 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'}
response = session.get(url)
soup = BeautifulSoup(response.content, "lxml")
for link in soup.select("div#content_findResults div#content_column1 ul li a[href*=MemberProfile]"):
print 'https://www.ohiobar.org' + link.get("href")
请建议我在这里做错了什么?
谢谢
【问题讨论】:
标签: python-2.7 web-scraping request beautifulsoup web-crawler