“Python Scrapy” Code-Antworten

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

Ähnliche Antworten wie “Python Scrapy”

Fragen ähnlich wie “Python Scrapy”

Weitere verwandte Antworten zu “Python Scrapy” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen