[ESP-ENG] Titulos y enlaces en geekfence || Titles and links in geekfence
0 comments

import httpx
from selectolax.parser import HTMLParserheaders={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75'}
url_list=['https://www.geekfence.com/category/computing/',
'https://www.geekfence.com/category/electronics/',
'https://www.geekfence.com/category/business/',
'https://www.geekfence.com/category/entrepreneur/']for url_list in url_list:
client=httpx.Client(headers=headers) geekfence=client.get(url_list).text with open('geekfence.html',mode='w',encoding="utf-8") as archive: archive.write(geekfence) archive.close() f=open('geekfence.html',encoding="utf-8") local_html=HTMLParser(f.read()) for hl in local_html.css('div.td-module-thumb > a,h3.entry-title.td-module-title > a '): headlines=hl.text() links=hl.attributes['href'] print(f'headlines:{headlines} links:{links}')


Comments