Initial commit

This commit is contained in:
Renne Rocha 2023-10-23 19:57:49 -03:00
commit b0b016a4d9
37 changed files with 2447 additions and 0 deletions

25
code/exercise-4.py Normal file
View file

@ -0,0 +1,25 @@
import scrapy
class QuotesViewStateSpider(scrapy.Spider):
name = "quotes_viewstate"
allowed_domains = ["quotes.toscrape.com"]
start_urls = ["http://quotes.toscrape.com/search.aspx"]
def parse(self, response):
authors = response.css("#author option::attr(value)").getall()
form_data = {
# TODO
}
for author in authors:
yield scrapy.FormRequest(
response.urljoin(response.css("form::attr(action)").get()),
callback=self.parse_author_tags,
formdata=form_data,
cb_kwargs={"author": author}
)
def parse_author_tags(self, response, author):
# TODO
...