python3系列-爬虫解析
来源:互联网 发布:人工智能计算器 iphone 编辑:程序博客网 时间:2024/06/05 08:31
import urllib.requestfrom bs4 import BeautifulSoupurl="http://www.biquge5200.com/52_52542/"req = urllib.request.Request(url)response = urllib.request.urlopen(req)data = response.read()data=data.decode("gbk")soup=BeautifulSoup(data)soup=BeautifulSoup(str(soup.find(id='list')))list=soup.find_all('a');for l in range(9,len(list)): print(list[l].get('href'),list[l].text)url="http://www.biquge5200.com/52_52542/150290199.html"req = urllib.request.Request(url)response = urllib.request.urlopen(req)data = response.read()data=data.decode("gbk")soup=BeautifulSoup(data)soup=BeautifulSoup(str(soup.find(id='content')))print(soup)
import urllib.requestfrom bs4 import BeautifulSoup# for u in range(1,1830):for u in range(0,1830): print(u) url="http://xiaohua.zol.com.cn/new/"+str(u)+".html" req = urllib.request.Request(url) response = urllib.request.urlopen(req) data = response.read() data=data.decode("gbk") soup=BeautifulSoup(data) soup=BeautifulSoup(str(soup.find(attrs={'class':'article-list'}))).find_all(attrs={'class':'article-summary'}) for i in soup: u="http://xiaohua.zol.com.cn"+i.find(attrs={'class':'article-title'}).find_all('a')[0].get('href') req = urllib.request.Request(u) response = urllib.request.urlopen(req) data = response.read() data = data.decode("gbk") cls = BeautifulSoup(data).find(attrs={'class':'wrapper location clearfix'}).find_all("a")[3].text title=BeautifulSoup(data).find(attrs={'class':'article-title'}).text content=BeautifulSoup(data).find(attrs={'class':'article-text'}).text fcontent=cls+"|||"+title+"|||"+content+"\n" # print(fcontent) with open("c:/dz.txt", 'a') as file: file.writelines(fcontent.replace(u'\xa0', u' '))
阅读全文
0 0
- python3系列-爬虫解析
- python3爬虫数据解析实战
- Python3.5爬虫urllib系列之三
- Python3网络爬虫快速入门实战解析
- python3 爬虫
- python3爬虫
- python3 爬虫
- Python3 爬虫
- Python3 爬虫基础系列教程(亲测有效)
- 聚沙成塔--爬虫系列(二)(python3基础语法)
- python3版本爬虫系列之模拟登陆CSDN
- Python3.X 爬虫实战(动态页面爬取解析)
- 【Python爬虫系列】内容解析之BeautifulSoup
- 爬虫系列8解析robots.txt
- 【爬虫系列】第二部分 网页解析Jsoup
- Python3网络爬虫快速入门实战解析(一小时入门 Python 3 网络爬虫)
- python3 多线程爬虫
- 自制 Python3爬虫
- Spark性能调优:调度分配更多资源
- IO流笔记
- Spring注解自我理解
- 静态成员变量和静态成员函数
- Android Studio下git的使用
- python3系列-爬虫解析
- rpm spec文件编写
- 11月英语 ---everything in my plan
- plsql developer使用
- JAVA SE — Day 18
- maven pom.xml
- IO流作业
- Spring Boot学习(二):Spring Boot的启动器Starter详解
- 遇到的403问题