Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """read dotabuff hero meta data"""
- from bs4 import BeautifulSoup
- import urllib.request
- dotabuff = "https://www.dotabuff.com/heroes/meta"
- local = "dotabuff.html"
- with open(local, encoding="utf-8") as f:
- stream = f.read()
- soup = BeautifulSoup(stream, "lxml")
- data = soup.table
- chars = data.find_all("tr")
- header1 = "blank, <2k, <2k , 2k-3k, 2k-3k, 3k-4k, 3k-4k, 4k-5k, 4k-5k, 5k+, 5k+"
- header2 = "hero, Pick%, Win%, Pick%, Win%, Pick%, Win% , Pick%, Win%, Pick%, Win%"
- content = ""
- for i in range (1, len(chars)):
- output = ""
- row = chars[i].find_all("td")
- for j in range(1,len(row)):
- output+=","+row[j].get_text()
- content += output[1:]+"\n"
- #print(output)
- with open("dotaheroes.csv", "w", encoding="utf-8") as file:
- file.write(header1+"\n")
- file.write(header2)
- file.write(content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement