Skip to content

Instantly share code, notes, and snippets.

@staticor
Created August 19, 2013 05:39
Show Gist options
  • Select an option

  • Save staticor/6266000 to your computer and use it in GitHub Desktop.

Select an option

Save staticor/6266000 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import urllib2
import re
html=urllib2.urlopen("http://www.baidu.com/s?wd=seo&rn=100").read()
soup=BeautifulSoup(html)
results = soup.find_all(class_=re.compile("result"))
for links in results:        
         print links.h3.get_text()
         print links.span.get_text()
 
按下f5 得到结果
seo_百度百科
SEO综合查询 - 站长工具
 seo.chinaz.com/ 2012-11-14  
搜外SEO论坛-人气最旺的SEO行业社区,时刻交流搜索引擎技术更新...
  www.seowhy.com/bbs/ 2012-11-14  
SEO每天一贴 – Zac的搜索引擎优化博客。嗯,这个才是官方网站。
  www.seozac.com/ 2012-11-2  
百度SEO优化_外链及关键词SEO工具_百度站长平台
百度搜索引擎优化指南 Baidu SEO Guide 2.0 - seo培训入门必读
  baiduseoguide.com/ 2012-10-31  
seo_百度词典
SEO Company | Search Engine Optimization Firm - GreenCowSEO.com
  www.greencowseo.com/ 2012-11-14  
合肥优派&UPAI SEO/SEM优化中小企业营销利器.
  www.upai.net.cn/ 2012-10-15 
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment