简体   繁体   English

使用 Scrapy 和 Python 2.7 抓取网页

[英]Crawl A Web Page with Scrapy and Python 2.7

Link: http://content.time.com/time/covers/0,16641,19230303,00.html [new DOM link]链接: http : //content.time.com/time/covers/0,16641,19230303,00.html 【新增DOM链接】

Cover Page Html tag封面 Html 标签

How to get that SCR in Jason and download images如何在Jason 中获取SCR下载图像

在此处输入图片说明

Next Button Tag下一个按钮标签

在此处输入图片说明

I want to scrap this 2 links using Scrapy我想使用Scrapy废弃这 2 个链接

Any Help !!任何帮助!

I need to write a method to download images and click on next page, run them in for loop till final image get the download(Final Page).我需要编写一种方法来下载图像并单击下一页,在 for 循环中运行它们直到最终图像获得下载(最终页面)。 how to download rest of part ill figure it out.如何下载剩下的部分生病了。

I follow this tutorial https://www.pyimagesearch.com/2015/10/12/scraping-images-with-python-and-scrapy/我按照本教程https://www.pyimagesearch.com/2015/10/12/scraping-images-with-python-and-scrapy/

[DOM is already outdated ] [DOM 已经过时]

I've already set all files and Pipelines for project我已经为项目设置了所有文件和管道

For Record, I tried different Different method XPath css response对于记录,我尝试了不同的不同方法 XPath css 响应

https://github.com/Dhawal1306/Scrapy https://github.com/Dhawal1306/Scrapy

Everything is done solution is on Github 4700 somewhere images we have and along with JSON also.一切都完成了,解决方案在 Github 4700 上,我们拥有图像以及 JSON。

for a tutorial, any question you just have to ask !!对于教程,您只需提出任何问题!!

I know this is not scrapy but I found easier using BS4.我知道这不是scrapy,但我发现使用BS4更容易。 so you have to "pip install beautifulsoup4".所以你必须“pip install beautifulsoup4”。 Here is a sample :这是一个示例:

import requests
from bs4 import BeautifulSoup
import os

r = requests.get("https://mouradcloud.westeurope.cloudapp.azure.com/blog/blog/category/food/")
data = r.text
soup = BeautifulSoup(data, "lxml")

for link in soup.find_all('img'):
        image_url = link.get("src")
        print(image_url)

It worked like a charm它就像一个魅力

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM