I'm a total newbie on scraping but I have started on a small project using Python 3.4 For some reason the following code does not submit properly. In my first attempt I basically only want to hit "searh"("Sök") on a webform.
The code I have used is:
import urllib.parse
import urllib.request
url = 'http://www.kkv.se/Diariet/default.asp?nav=2'
values = { 'action' : 'S%F6k',
'dossnr_from' : '0',
'dossnr_tom' : '0',
'hits_page' : '10',
'hits_search' : '50',
'sort' : 'Regdatum',
'sortorder' : 'Fallande'}
data = urllib.parse.urlencode(values)
print(values)
data = data.encode('utf-8')
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
the_page = response.read()
print(the_page)
I also tried submitting the post results (that I find in Firebug after manually posting):
url_values = 'diarienr=&diaryyear=&text_arendemening=&text_avsandare=®datum_from=&
regdatum_tom=&beslutsdatum_from=&beslutsdatum_tom=&dossnr_from=0&dossnr_tom=0&
hits_page=10&sort=Regdatum&hits_search=50&sortorder=Fallande&action=S%F6k'
url = 'http://www.kkv.se/Diariet/default.asp?nav=2'
full_url = url + '?' + url_values
data = urllib.request.urlopen(full_url)
print(data.read())
But both codes only spit out the source of the starting url. Can anyone please help me to point me in the correct direction?
Thank you very much for your help. Equilib