码迷,mamicode.com
首页 > 其他好文 > 详细

9.2 sun.py

时间:2019-05-02 18:21:32      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:int   get   webkit   php   com   sel   safari   data   index   

import requests
from bs4 import BeautifulSoup

url = 'http://wz.sun0769.com/index.php/question/reply?page=0'
headers = {
    'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
}
data = requests.get(url, headers=headers).content

# with open('sun.html', 'wb') as f:
#     f.write(data)

soup = BeautifulSoup(data,'lxml')

result = soup.select('a[class=news14]')

print(len(result))

9.2 sun.py

标签:int   get   webkit   php   com   sel   safari   data   index   

原文地址:https://www.cnblogs.com/hankleo/p/10802734.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!