Hier einzureichen ist eine Probe von meinem Code mit urllib und urllib2: diese NachrichtIch kann Feld mit urllib nicht ausfüllen, urllib2, Bibliotheken mechanisieren, ich möchte eine Form
import urllib
import urllib2
url = 'http://example.com/schedule-appointment.php'
name = "Name:"
phone = "Phone:"
email = "E-mail:"
office = "Office:"
rq_date = "Requested date and time:"
alt_date = "Alternative date and time:"
comments = "Reason for visit:"
values = {
name : "Vasya",
phone : "1234567890",
email : "[email protected]",
office : "Madison Ave (NYC)",
rq_date : "01/29/2017 10:00 am" ,
alt_date : "01/29/2017 10:00 am",
comments : "this is a test"
}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print(the_page)
und bekam: { "status ": false," msg ":" Bitte füllen Sie alle Felder "}
und ein weiteres Beispiel mit mechanize.
import mechanize
br = mechanize.Browser()
urlofmypage = 'http://www.example.com/schedule-appointment.php'
br.open(urlofmypage)
print(br.geturl())
br.select_form(nr=0)
br['Name:'] = ['Vasya']
br['Phone:'] = ['1234567890']
br['E-Mail:'] = ['[email protected]']
br['Office:'] = ['Madison Ave (NYC)']
br['Requested date and time:'] = ['01/29/2017 10:00 am']
br['Alternative date and time:'] = ['01/29/2017 10:00 am']
br['Reason for visit:'] = ['this is a test']
result = br.submit()
print(result)
dass bekam: 012.http://www.example.com/schedule-appointment.php
Traceback (most recent call last): File "/Users/vasyaiv/Desktop/Automation test Python/draft.py", line 68, in br.select_form(nr=0) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mechanize/_mechanize.py", line 524, in select_form raise FormNotFoundError("no form matching "+description) FormNotFoundError: no form matching nr 0
Irgendwelche Ideen?
Bitte posten Sie die relevanten PHP-Dateien wie durch diese Fehler angezeigt: '{" status ": false," msg ":" Bitte füllen Sie alle Felder aus. "}' - Welche Felder? 'FormNotFoundError: no form matching nr 0' - welche Form? Wenn "blabla.com" nur ein Platzhalter ist, verwenden Sie bitte "example.com", da mein Arbeitsproxy "blabla.com" nicht mag. –