from requests_html import HTMLSession session = HTMLSession() response = session.get('https:.....').text r = response.xpath('//*[@id="blgtble"]/tbody')
Что нужно прописать, чтобы response работало с xpath ?
спс!
from requests_html import HTMLSession session = HTMLSession() response = session.get('https:.....').text r = response.xpath('//*[@id="blgtble"]/tbody')
XPath is also supported (learn more):>>> r.html.xpath('a') [<Element 'a' class='btn' href='https://help.github.com/articles/supported-browsers'>]
r = session.get(url) r.html.xpath('a')
r = response.html.xpath('//*[@id="blgtble"]/tbody')
response = session.get('https:.....').text
while True: try: random_proxy = random.choice(proxies) random_proxy = {'http': random_proxy, 'https': random_proxy} resp = session.get(url, proxies=random_proxy, timeout=2) if resp.status_code == 200: break except Exception as e: print(type(e), e) # rand_sleep = random.randint(10, 30) # sleep(rand_sleep) print(url, resp.status_code) links = resp.html.xpath("//div[@class='r']/a/@href") domains = [x.split('/')[2].replace('www.', '') for x in links if 'http' in x] print("Keyword - ", key)
sasholyТак можно и голову раздолбить
а вот такой кусок нашел и долблюсь
links = resp.html.xpath("//div[@class='r']/a/@href")
response = session.get('https:.....').text
sasholyПотому что ты не убрал .text в конце.
если имели ввиду html, то все равно
AttributeError: ‘str’ object has no attribute ‘html’
from requests_html import HTMLSession session = HTMLSession() response = session.get('https:.....') r = response.xpath('//*[@id="blgtble"]/tbody')
from requests_html import HTMLSession session = HTMLSession() response = session.get('https://free-proxy-list.net/') r = response.xpath('//*[@id="proxylisttable"]/tbody') for i in r: if i.xpath('//*[@id="proxylisttable"]/tbody/tr[*]/td[7]').text == 'yes': ip = i.xpath('//*[@id="proxylisttable"]/tbody/tr[*]/td[1]').text port = i.xpath('//*[@id="proxylisttable"]/tbody/tr[*]/td[2]').text print(ip, port, )
sasholy
вот пытаюсь собрат в кучу, пытаюсь чужой код переделать на xpath
from requests_html import HTMLSession session = HTMLSession() response = session.get('https://free-proxy-list.net/') r = response.html n = 0 for txt in r.xpath('//*[@id="proxylisttable"]/tbody/tr/td[7]/text()'): n+=1 if txt == "yes": data = r.xpath(f'//*[@id="proxylisttable"]/tbody/tr[{n}]/td[1]/text() | //*[@id="proxylisttable"]/tbody/tr[{n}]/td[2]/text()') ip = data[0] port = data[1] print(f'{ip}:{port}')
158.101.198.195:3128 37.152.181.36:8118 1.20.103.196:42792 118.174.220.14:43473 117.252.12.26:55443 191.242.182.132:8081 79.137.254.51:60779 103.208.200.114:23500 191.100.24.251:21776 91.211.107.204:41258 203.207.52.206:8085 Process finished with exit code 0
xam1816спс, есть мануалы, чем руководствовался?