Created
April 30, 2023 16:23
-
-
Save sputnick-dev/88771f580872a6a0fed780105fddce98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
user = 'xxxxxxx' | |
password = 'xxxxxxxx' | |
import requests | |
from lxml import html | |
login_url = 'https://forum.ubuntu-fr.org/login.php' | |
session = requests.session() | |
response = session.get(login_url) | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0' | |
} | |
login_data = { | |
'form_sent': 1, | |
'redirect_url': 'https://forum.ubuntu-fr.org/index.php', | |
'req_username': user, | |
'req_password': password, | |
'login': 'Identification' | |
} | |
response = session.post(login_url + '?action=in', data=login_data, headers=headers) | |
res = session.get( | |
'https://forum.ubuntu-fr.org/search.php?action=show_new', | |
) | |
doc = html.fromstring(res.text) | |
nodes = doc.xpath('//table/tbody/tr/td[@class="tcl"]/div[@class="tclcon"]/div/strong/a') | |
for elt in nodes: | |
url = 'https://forum.ubuntu-fr.org/' + elt.get('href') | |
text = elt.text | |
print(url, text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment