Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sputnick-dev/88771f580872a6a0fed780105fddce98 to your computer and use it in GitHub Desktop.
Save sputnick-dev/88771f580872a6a0fed780105fddce98 to your computer and use it in GitHub Desktop.
#!/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