vendredi 1 juillet 2016

Scraping a table from webpage with Python

from bs4 import BeautifulSoup
from urllib import urlopen

player_code = open("/Users/brandondennis/Desktop/money/CF_Name.txt").read()
player_code = player_code.split("r")


for player in player_code:

html =urlopen("https://www.capfriendly.com/players/"+player+"")

soup = BeautifulSoup(html, 'html.parser')

for section in soup.findAll('div',{"class": "table_c"}):
    table = section.findChildren()[10].text
    print player, table

Here is a link to a sample player page : https://www.capfriendly.com/players/patrik-elias

Here is a sample of player names that I am adding from a text file to the base url.

enter image description here

This is ultimately What I am wanting to do for my text file of 1000+ players

This is ultimately what I am wanting to do for my text file of 1000+ players

Aucun commentaire:

Enregistrer un commentaire