을 제출하려면, URLLIB는, urllib2가이 라이브러리를 기계화 사용하여 필드를 채울 수없는 것은 URLLIB와 urllib2가 내 코드의 샘플입니다내가 형태 여기
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)
그 메시지를 받았습니다 : { "상태 "거짓"MSG는 ":"모든 필드를 작성하십시오 "}
및 기계화와 또 다른 예 :.
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)
가 도착를 :,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
어떤 아이디어가?
제발 내가 대상 페이지의 컨트롤의 ID 등 "이름", "전화"와 같은
당신은 목록과 텍스트 입력을 채우기 위해 시도보이는 것을 의심 '{ "status": false, "msg": "모든 필드를 기입하십시오."}'- 어떤 필드? 'FormNotFoundError : nr 0과 일치하는 형식 없음 '- 어떤 형식입니까? 또한, 'blabla.com'이 단지 자리 표시 자일 경우'blabla.com '을 싫어하기 때문에'example.com'을 사용하십시오. –