使用request.post时有适当的有效负载

时间:2017-01-28 12:42:23

标签: python beautifulsoup

显然是新手,但试图提交以下表单: https://apps.fcc.gov/oetcf/eas/reports/GenericSearch.cfm?calledFromFrame=N

到目前为止已经有了这个脚本,但不确定我是否完全理解了发布的有效负载。是否预期所有投入?

import requests
from bs4 import BeautifulSoup
import time

payload ={'grantee_code' : '', 
          'product_code' : '', 
          'product_exact_match' : '', 
          'applicant_name' : '',
          'grant_date_from' : '01/01/2017', 
          'grant_date_to' : '02/01/2017', 
          'comments' : '', 
          'application_purpose' : 'O', 
          'application_purpose_description' : '',
          'sdr_filings_only' : '', 
          'eas_apps_only' : '', 
          'tcb_apps_only' : '', 
          'composite_apps_only' : '',
          'grant_code_1' : '',
          'grant_code_2' : '', 
          'grant_code_3' : '', 
          'test_firm' : '', 
          'application_status' : '', 
          'application_status_description' : '',
          'equipment_class' : '', 
          'equipment_class_description' : '',
          'lower_frequency' : '2402', 
          'upper_frequency' : '2480', 
          'freq_exact_match' : '', 
          'bandwidth_from' : '', 
          'emission_designator' : '', 
          'tolerance_from' : '', 
          'tolerance_to' : '', 
          'tolerance_exact_match' : '', 
          'power_output_from' : '',
          'power_output_to' : '', 
          'power_exact_match' : '', 
          'rule_part_1' : '', 
          'rule_part_2' : '', 
          'rule_part_3' : '', 
          'rule_part_exact_match' : '', 
          'product_description' : '', 
          'modular_type' : '', 
          'modular_type_description' : '', 
          'tcb_code' : '', 
          'tcb_code_description' : '',
          'tcb_scope' : '',
          'tcb_scope_description' : '',
          'outputformat' : 'HTML',
          'show_records' : '499',
          'fetchfrom' : '0',
          'calledFromFrame' : 'N'
          }


url = 'https://apps.fcc.gov/oetcf/eas/reports/GenericSearchResult.cfm?RequestTimeout=500'
r = requests.post(url, payload)
soup = BeautifulSoup(r.text)

print(soup)

1 个答案:

答案 0 :(得分:1)

因此,这与python和请求无关,但更多地了解HTTP POST的工作原理以及如何调试。为此,以下问题和答案很有帮助,并指导我使其工作:

How can I debug a HTTP POST in Chrome?