Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scrapy
- import openpyxl
- class SolarKeyMarkSpider(scrapy.Spider):
- name = "solarkeymark_spider"
- start_urls = ["https://solarkeymark.eu/database/"]
- def parse(self, response):
- wb = openpyxl.Workbook()
- ws = wb.active
- ws.append(["Company Name", "Brand", "License Number", "η0", "b", "a1", "a2", "a3"])
- for row in response.xpath('//table[@id="Table1"]//tr'):
- tds = row.xpath('.//td')
- if len(tds) == 8:
- company_name = tds[0].xpath('./text()').get().strip()
- brand = tds[1].xpath('./text()').get().strip()
- license_number = tds[2].xpath('./text()').get().strip()
- η0 = tds[3].xpath('./text()').get().strip()
- b = tds[4].xpath('./text()').get().strip()
- a1 = tds[5].xpath('./text()').get().strip()
- a2 = tds[6].xpath('./text()').get().strip()
- a3 = tds[7].xpath('./text()').get().strip()
- ws.append([company_name, brand, license_number, η0, b, a1, a2, a3])
- wb.save("solarkeymark_results.xlsx")
Advertisement
Add Comment
Please, Sign In to add comment