【问题标题】:How to get a specific link for web scraping如何获取网页抓取的特定链接
【发布时间】: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


    【解决方案1】:

    进口机械化 http://wwwsearch.sourceforge.net/mechanize/documentation.html 将它与 BeautifulSoup 一起使用应该可以为您提供结果 你正在寻找。 更多文档。 http://www.ibm.com/developerworks/web/library/l-python-mechanize-beautiful-soup/index.html?ca=dat

    【讨论】:

      猜你喜欢
      • 2020-03-15
      • 2020-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多