Crawling iQIYI hot search

# Love Fantastic Art Web site: http: //v.iqiyi.com/index/resou/index.html

Requests Import
from the BeautifulSoup BS4 Import
Import PANDAS AS PD
URL = 'HTTP: //v.iqiyi.com/index/resou/index.html'# search URL
headers = {' User-Agent: Mozilla / 5.0 (Windows NT 10.0; win64; x64) AppleWebKit / 537.36 ( KHTML, like Gecko) Chrome / 70.0.3538.102 Safari / 537.36 Edge / 18.18363 '} # camouflage crawler
r = requests.get (url) # get request transmitted
r.encoding = r.apparent_encoding # unified encoding
soup = BeautifulSoup (r.text, 'lxml ') # SOUP objects
a = [] # create tables
B = []
for Y in soup.find_all (class _ = "title--Box. 1"):
a.append (Y .get_text () Strip ()).
for X in soup.find_all (class _ = "title--Box. 3"):
b.append (x.get_text (). Strip ())
Data = [title, index]
Print ( Data)
C = pd.DataFrame (Data, index = [ "title", "heat"]) # Visualized
print (cT)

 

Gets the title of heat

 

The results

 

Guess you like

Origin www.cnblogs.com/cwddbky/p/12526989.html