i am scraping a website. I want to send a post request with form data to a url.
I have been able to achieve that in python but in javascript i am not receiving the proper response
# python
import requests
response = requests.post(
url = 'https://savings.gov.pk/latest/results.php',
data= {
'country' : '1',
'state' : 'all',
'range_from' : '000000',
'range_to' : '000100',
'pb_number_list': '',
'btnsearch' : 'Search'
}
)
print(response.text.find('class="divTable"'))
>>> 11699
// javascript
import axios from 'axios'
let response = await axios.post(
'https://savings.gov.pk/latest/results.php',
{
country : '1',
state : 'all',
range_from : '000000',
range_to : '000100',
pb_number_list: '',
btnsearch : 'Search'
}
)
console.log(response.data.search('class="divTable"'))
>>> -1
I am using axios library for javascript, I believe I am not receiving the correct response because I am not passing the data correctly.
any idea how should I be passing the data? if this is achieved using a different library than that is also acceptable.