导入并自动将表从外部网站更新为sql

时间:2015-04-24 16:33:41

标签: mysql sql database

我正在创建一个足球运动员搜索系统,并希望将实时统计数据实施到我的数据库中。我已获得opta sport的许可,可以为我的项目使用他们的数据。

我想每周提取的数据在这里:

http://www.whoscored.com/Regions/252/Tournaments/2/Seasons/4311/Stages/9155/PlayerStatistics/England-Premier-League-2014-2015

看起来如此:

R| Name | ..........Apps|   Mins|   Goals|  Assists |Yel|   Red|    SpG|    PS%|    AerialsWon| MotM

1|  Eden Hazard |  ...32 |      2841|   .....13| ..........8|    2| ....... -|  .2.1 |  86.9|   0.4 ..............|      9  

请忽略' ....'它们只是为了保持信息在这里看起来应该如何。

我的问题是:

问题1:我无权访问网站数据库。

问题2:我不知道如何将数据直接提取到我的sql server中。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我会使用python。我每周都会抓取网页并读入数据。如果您观察到该页面的HTML,则所有必需的数据都会显示在ID为 top-player-stats-summary-grid 的表格中。您可以使用BeautifulSoup

from bs4 import BeautifulSoup as soup
 table = soup.find(id="top-player-stats-summary-grid")

表变量现在保存您想要的数据。这里以更好的方式在字典中排列数据。 Parse HTML table to Python list?