Recently bored in writing Python crawler, share a crawl to the NBA today Information Python script, may not be written beautiful, have optimized please big God guidance!
? /test sudo vim nba.py#!/usr/bin/python#-*- coding:utf-8 -*-class url: def __init__ (Self,url): self.url = url def nba (self): import re import urllib2 hearders = "User-agent", "mozilla/5.0 (windows nt &NBSP;10.0;&NBSP;WOW64) AppleWebKit/537.36 (Khtml, like gecko) chrome/60.0.3112.113 safari/537.36 " url =&nBSP; " %s " % (Self.url) par = ' 2018-01-25.*htm\ ' > (. *?) </a></li> ' opener = urllib2.build_opener () opener.addheaders = [hearders] urllib2.install_opener (opener) html = Urllib2.urlopen (URL). read (). Decode ("Utf-8") data = re.findall (par,html) print type (data) &NBSP;&NBSp; for i in data: print iu = url (' https://news.zhibo8.cc/nba/') U.nba ()
? /test sudo python nba.py<type ' list ' > ' translation Group ' The Warrior's "death five small" this season, why is the rule greatly reduced? Jimmy Butler Sun and Wade Photo: Happy Birthday to Big Brother ' bad basket tree '! O ' Neill's self-chopped basket Durant: The Rockets are very tough. Their change is not just CP3 Anthony 27 points Adams 21+10 Thunder victory Lakers welcome 3 Streak Hayward Tweet: Love our team's morale Leonard comeback 19+8 Jokich 23+9+7 Spurs home win gold nuggets platinum pressure whistle hack buckle for Knicks renew two teams into the second overtime 27 minutes 20 board! Letter brother outbreak away double kill wizards blades not old! Nowitzki 20 points team to meet the lone man "first win" George absent Wei 31+8+6 melon 11+11 Thunder by Basket Net Reversal Library elected all-star Western ticket King! will become captain of the West! After Butler race: we need to be humble we're glad we lost the game. Forward-Pioneer vs Walker: The two compete, the Brave wins Embid: a wonderful day! Great victory + become all-Star Griffin: Lillard deserves to be selected All-star rather than just in the scope of the discussion! Wall wins season 16 assists forward-Spurs vs Walker: Five connected guests end up with Silver Devils
Python crawling information for the NBA today