Last active
April 19, 2017 11:06
-
-
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.
This file contains hidden or 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
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