import requests
from bs4 import BeautifulSoup
r = requests.get("http://stackoverflow.com/questions/29336915/python-scraping-webpages")
# find all a tags with href attributes
for a in BeautifulSoup(r.content).find_all("a",href=True):
# print each href
print(a["href"])
显然,这是一个非常广泛的例子,但会让你开始,如果你想要特定的网址,你可以缩小你的搜索某些元素,但这将是不同的所有网页。没有比requests和BeautifulSoup更容易用于解析的工具了
相关问题 更多 >
编程相关推荐