Skip to content

Instantly share code, notes, and snippets.

@billmetangmo
Created July 6, 2023 21:52
Show Gist options
  • Select an option

  • Save billmetangmo/fbd319e33e30332db3e57f8ea56ec27c to your computer and use it in GitHub Desktop.

Select an option

Save billmetangmo/fbd319e33e30332db3e57f8ea56ec27c to your computer and use it in GitHub Desktop.
compta_online
import urllib2
from bs4 import BeautifulSoup
url = "https://www.compta-online.com/oubli-de-facturation-facture-faite-posteriori-t72224#NULL"
response = urllib2.urlopen(url)
html = response.read()
soup = BeautifulSoup(html, 'html.parser')
# Find the input element with the name 'text'
input_element = soup.find('input', {'name': 'text'})
# Get its value (which is a URL)
if input_element is not None:
new_url = input_element.get('value')
# Now fetch the new URL
new_response = urllib2.urlopen(new_url)
new_html = new_response.read()
new_soup = BeautifulSoup(new_html, 'html.parser')
# Get all the text from the new page
full_text = new_soup.get_text()
# Find the start and end markers in the text
start_marker = "ImprimerLienAlerter"
end_marker = "Répondre"
start = full_text.find(start_marker)
end = full_text.find(end_marker)
if start != -1 and end != -1:
# Extract the text between the markers
extracted_text = full_text[start+len(start_marker):end]
print(extracted_text)
else:
print("Markers not found in the text.")
else:
print("No input element with the name 'text' found.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment