python爬虫爬取微信_python爬虫对搜狗抓取微信搜索信息不全问题

刚开始学习python爬虫,想实现对搜狗公众号搜索结果的爬取

发现问题是抓到的信息没有直接在浏览器访问的URL信息完整。

以下是基本实现,代码很简单,爬取到的页面中没有“最近文章”(在浏览器中直接访问有“最近文章”内容)

请高手们指点一二,谢谢!

#-*- coding: utf-8 -*-

import urllib2

import sys

import urllib

from bs4 import BeautifulSoup

reload(sys)

sys.setdefaultencoding('utf8')

url = 'http://weixin.sogou.com/gzh?openid=oIWsFt5l9RDYeAjdXZBYtGzbH0JI'

print url

i_headers = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0"}

req = urllib2.Request(url, headers=i_headers)

content = urllib2.urlopen(req).read()

soup = BeautifulSoup(content)

print soup

siteUrls = soup.findAll(attrs={'class':'img_box2'})

print siteUrls

file_object = open('test.htm','w+')

file_object.write(content)

file_object.close()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值