Answer the question
In order to leave comments, you need to log in
How to specify ::before when writing to html file?
I have photo scraping code
import scrapy
class RedditSpider(scrapy.Spider):
name = 'avt'
start_urls = ['https://www.avito.ru/sankt-peterburg/avtomobili/mazda_6_2008_1947668359']
def parse(self, response):
links = response.xpath('//img[contains(@src, "img.avito")]/@src')
html = ""
for link in links:
url = link.get()
if any(extension in url for extension in ['.png', 'jpg', 'gif']):
html += """<a href="{url}"
target="_blank">
<img src="{url}" height="33%"
width="33%"/>
<a/>""".format(url=url)
with open('img.html', 'a') as file:
file.write(html)
<div class="gallery-list-item-link">
::before
<img src="//79.img.avito.st/75x55/8691702679.jpg" alt="Mazda 6, 2008, с пробегом, цена 450 000 руб.">
</div>
::after
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question