Advertisement
furas

Python - scraping example

Jun 10th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. import urllib
  2. from bs4 import BeautifulSoup as bs4
  3.  
  4. target = "https://en.wikipedia.org/wiki/List_of_El_Clasico_matches"
  5.  
  6. def wiki(url):
  7.     data = bs4(urllib.urlopen(url).read(), "lxml")
  8.     sv = []
  9.  
  10.     for i in data.table.find_all('td')[3:8]:
  11.         if "Barcelona" in i:
  12.             sv.append(["B", 0])
  13.         if "Real" in i:
  14.             sv.append(["R", 0])
  15.         if i.b and '–' in i.b.contents[0]:
  16.             print i.b.contents[0], i.b
  17.             #print ",".join(i.b.contents), i.b
  18.  
  19. print 'short dash:', "-", ord("-")
  20. print ' long dash:', u"–", ord(u"–")
  21.  
  22. wiki(target)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement