You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
475 B

from urllib.request import urlopen, Request
from bs4 import BeautifulSoup
def findnth(list_, keyword, n):
parts = list_.split(keyword, n + 1)
if len(parts) <= n + 1:
return -1
return len(list_) - len(parts[-1]) - len(keyword)
def get_items(url):
src = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
webpage = urlopen(src).read()
return str(BeautifulSoup(webpage, "html.parser").find("table", class_="ta")).split("<tr")