Skip to content

Instantly share code, notes, and snippets.

@amitness
Last active April 19, 2017 11:06
Show Gist options
  • Save amitness/b1031109e0bdd8307533b0dbd27ea6cc to your computer and use it in GitHub Desktop.
Save amitness/b1031109e0bdd8307533b0dbd27ea6cc to your computer and use it in GitHub Desktop.
A gist to teach someone how to send post requests using requests library.
import requests
from bs4 import BeautifulSoup
payload = {
'keyword': '20403105',
'slug': 'SearchResult'
}
response = requests.post('http://www.neb.gov.np/result/search', data=payload)
soup = BeautifulSoup(response, 'lxml')
# Gives output like: Congratulation!! FirstName LastName ,
h1_text = soup.find('h1', {'class': 'text-success text-center'}).text
# Extract only name from that text
print h1_text.lstrip('Congratulation!! ').rstrip(', ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment