【发布时间】:2014-05-11 05:37:03
【问题描述】:
我正在编写一个程序来获取足球运动员的市场价值并且它有效
from bs4 import *
import requests
def marketvalue():
reply = str(input("Enter the player whose current market value you wish to know \n"))
url = ("http://www.transfermarkt.com/en/first-last/profil/playerid.html")
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data)
mydivs = soup.findAll("td", {"class" : "note"})
value = str(mydivs[0].get_text())
print("Current value of {0} is {1}".format(reply, value))
问题在于播放器的 URL 是基于看似随机的 playerid。反正有没有使用请求或汤来获得这个?
【问题讨论】:
标签: python web-scraping beautifulsoup python-requests