基本Web爬虫没有输出(Basic Web crawler no output)

编程入门 行业动态 更新时间:2024-10-05 23:23:45
基本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?

更多推荐

本文发布于:2023-08-07 11:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464116.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:爬虫   Web   Basic   output   crawler

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!