基于beatifulsoup写一下简单的网络爬虫
来源:互联网 发布:yy挂机软件 编辑:程序博客网 时间:2024/06/02 02:21
1、目的,抓取mediawiki中 id="mw-content-text" 的内容,并再向下读取一层,最终可以把数据以文件或是数据库形式保存起来.
import urllib2
import lxml
import time
from bs4 import BeautifulSoup
searchroot = 'http://wiki.t-firefly.com/';
response = urllib2.urlopen("http://wiki.t-firefly.com")
def entrysecparse(url):
"entry second parse func"
print url
time.sleep(3)
soupitem = BeautifulSoup(urllib2.urlopen(url))
print soupitem.prettify()
test = soupitem.find_all("div", id="mw-content-text")
print test
#function_suite
return 0
#print response.read()
#soup = BeautifulSoup(open('http://xxxx.t-firefly.com'))
soup = BeautifulSoup(response.read())
#print soup.prettify()
test = soup.find_all("div", id="mw-content-text")
print test
test = test[0];
#print test;
#new = BeautifulSoup(test)
#print new;
href = test.find_all('a')
#href = BeautifulSoup(test).find_all('a')
print href;
for item in href:
print 'item :',item
itemurl = item.get('href')
print itemurl;
if itemurl[0] == '/':
entrysecparse(searchroot + itemurl)
- 基于beatifulsoup写一下简单的网络爬虫
- 基于Jsoup实现的简单网络爬虫
- Python写的网络爬虫程序(很简单)
- 简单的网络爬虫
- WebMagic写的网络爬虫
- WebMagic写的网络爬虫
- WebMagic写的网络爬虫
- WebMagic写的网络爬虫
- WebMagic写的网络爬虫
- WebMagic写的网络爬虫
- WebMagic写的网络爬虫
- WebMagic写的网络爬虫
- 基于WebKit的网络爬虫
- 基于WebKit的网络爬虫
- 基于python3的网络爬虫
- 基于scrapy的简单爬虫
- 手把手教你写基于C++ Winsock的图片下载的网络爬虫
- 手把手教你写基于C++ Winsock的图片下载的网络爬虫
- 安卓软键盘弹出底部变形问题解决方案
- UVa 11344
- RecycleView控件的使用(二) 为RecyclerView添加头文件和尾部文件
- PHP处理微信中带Emoji表情的消息发送和接收(Unicode字符转码编码)
- 纯干货,Spring-data-jpa详解,全方位介绍。
- 基于beatifulsoup写一下简单的网络爬虫
- Swagger的三个常用注解
- Android Activity生命周期之屏幕切换与应用的响应性
- Python变量
- Atcoder Grand Contest 016F
- 70. Climbing Stairs dynamic programming
- hibernate4配置c3p0连接池报错
- SDK更新不了问题解决
- php处理base64编码和Unicode客户端交互的问题[z]