【问题标题】:Proper payload when using request.post使用 request.post 时的正确有效负载
【发布时间】:2017-06-14 01:49:39
【问题描述】:

显然是抓取新手,但尝试提交以下表单: 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)

【问题讨论】:

    标签: python beautifulsoup


    【解决方案1】:

    所以这与 python 或请求无关,而是更多地了解 HTTP POST 的工作原理以及如何调试它。为此,以下问题和答案很有帮助,并指导我让它发挥作用:

    How can I debug a HTTP POST in Chrome?

    【讨论】:

      猜你喜欢
      • 2014-09-27
      • 2017-08-16
      • 2012-08-02
      • 1970-01-01
      • 2018-01-25
      • 1970-01-01
      • 1970-01-01
      • 2016-08-05
      • 1970-01-01
      相关资源
      最近更新 更多