我试过使用{“a”,{“target”:“\u blank”})来获取这个列表中的网址,但这不起作用。你知道吗
在这种情况下,什么才是正确的刮链方法?我应该使用{“target”:“something”}还是{“href”:“something”}?你知道吗
import requests
from bs4 import BeautifulSoup
url = "http://www.gym-directory.com/listing/bulldog-gym/"
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
print soup.find("span",{"class":"wlt_shortcode_TITLE"}).text
print soup.find("span",{"class":"wlt_shortcode_map_location"}).text
print soup.find("span",{"class":"wlt_shortcode_phoneNum"}).text
print soup.find("span",{"class":"wlt_shortcode_EMAIL"}).text
print soup.find("a",{"target":"_blank"}).text
您需要
href
:相关问题 更多 >
编程相关推荐