基本Web爬虫没有输出(Basic Web crawler no output)
我在ubuntu 14.04上运行python 2.7.6!
我设计了一个基本的网络爬虫,它应该输出页面上的所有链接和相应的标题。 但它没有输出。
#!usr/bin/python3 from bs4 import BeautifulSoup import requests def web_crawl(url): source_code=requests.get(url) plain_text=source_code.text soup=BeautifulSoup(plain_text) for link in soup.findAll('a', {'class':"pu-image fk-product-thumb" }): href="http://www.flipkart.com" + link.get('href') print(href) title=link.string print(title) web_crawl('http://www.flipkart.com/laptops/pr?p%5B%5D=facets.availability%255B%255D%3DExclude%2BOut%2Bof%2BStock&p%5B%5D=sort%3Dpopularity&sid=6bo%2Cb5g&otracker=clp_computers-laptops_CategoryLinksModule_0-2_catergorylinks_0_AllBrands')它只是运行,没有输出! 有人可以帮忙吗?
I m running python 2.7.6 on ubuntu 14.04!
I designed a basic web crawler which should output all the link and corresponding titles on a page. but it is giving no output.
#!usr/bin/python3 from bs4 import BeautifulSoup import requests def web_crawl(url): source_code=requests.get(url) plain_text=source_code.text soup=BeautifulSoup(plain_text) for link in soup.findAll('a', {'class':"pu-image fk-product-thumb" }): href="http://www.flipkart.com" + link.get('href') print(href) title=link.string print(title) web_crawl('http://www.flipkart.com/laptops/pr?p%5B%5D=facets.availability%255B%255D%3DExclude%2BOut%2Bof%2BStock&p%5B%5D=sort%3Dpopularity&sid=6bo%2Cb5g&otracker=clp_computers-laptops_CategoryLinksModule_0-2_catergorylinks_0_AllBrands')It just runs and gives no output! can anyone help?
更多推荐
发布评论