“Python Scrapy” Réponses codées

Python Web Crawler

import scrapy

class BlogSpider(scrapy.Spider):
    name = 'blogspider'
    start_urls = ['https://blog.scrapinghub.com']

    def parse(self, response):
        for title in response.css('.post-header>h2'):
            yield {'title': title.css('a ::text').get()}

        for next_page in response.css('a.next-posts-link'):
            yield response.follow(next_page, self.parse)
Terrible Turkey

Py Scrapy

import time
import webbrowser
import requests
from datetime import datetime

found = False
while not found:
    today = datetime.today()
    try:
        r = requests.get(url = API_URL)
        data = r.json()
        next_slot = datetime.strptime(data['next_slot'], '%Y-%m-%d')
        print(f'Next slot: {next_slot}')
        if((next_slot - today).days < 1):
            webbrowser.open(URL)
            found = True
        else:
            time.sleep(10)
    except KeyError:
        continue
Amused Alligator

Python Scrapy

scrapy default error
Xerothermic Xenomorph

Réponses similaires à “Python Scrapy”

Questions similaires à “Python Scrapy”

Plus de réponses similaires à “Python Scrapy” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code