逆向基础 之定位基础

受害者网站 需要魔法

aHR0cHM6Ly93d3cucmVndWxhdGlvbnMuZ292Lw==

1 获取数据 根据页面的显示 定位到请求的URL 

 

2 找到了headers 有个 X-Api-Key 这个参数 就是一个加密的字段 

 

 3 搜一下这个字段是怎么生成的  为什么确定是这个呢 因为找的是生成的 就是response返回中找 前几个都是在header中

4  上代码

import re
import requests

headers = {
    'authority': 'www.regulations.gov',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'origin': 'https://www.regulations.gov',
    'referer': 'https://www.regulations.gov/',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
}

response = requests.get('https://www.regulations.gov/',  headers=headers,timeout=20)
#第一次 请求获取x-api-key
api_key= re.search('apiKey%22%3A%22(.*?)%22%2C%22api',response.text).group(1)

print('第一次获取apikey', api_key) 
# 把 Apikey 更新到header中
headers.update({'x-api-key':api_key})
params = {
    'filter[numberOfDays]': '7',
}
#  再次请求 返回数据
response = requests.get('https://api.regulations.gov/v4/whats-trending', params=params, headers=headers)
print(response.text)

请求结果

{
  "data" : [ {
    "id" : "BLM-2023-0005-0001",
    "type" : "whats-trending",
    "attributes" : {
      "documentType" : "Proposed Rule",
      "agencyId" : "BLM",
      "commentEndDate" : "2023-09-23T03:59:59Z",
      "title" : "Fluid Mineral Leases and Leasing Process"
    },
    "links" : {
      "self" : "https://api.regulations.gov/v4/whats-trending/BLM-2023-0005-0001"
    }
  }, {
    "id" : "FWS-R2-ES-2022-0162-0001",
    "type" : "whats-trending",
    "attributes" : {
      "documentType" : "Proposed Rule",
      "agencyId" : "FWS",
      "commentEndDate" : "2023-09-02T03:59:59Z",
      "title" : "Endangered and Threatened Species: Status for the Dunes Sagebrush Lizard"
    },
    "links" : {
      "self" : "https://api.regulations.gov/v4/whats-trending/FWS-R2-ES-2022-0162-0001"
    }
  }, {
    "id" : "EEOC-2023-0004-0001",
    "type" : "whats-trending",
    "attributes" : {
      "documentType" : "Proposed Rule",
      "agencyId" : "EEOC",
      "commentEndDate" : "2023-10-11T03:59:59Z",
      "title" : "Regulations To Implement the Pregnant Workers Fairness Act"
    },
    "links" : {
      "self" : "https://api.regulations.gov/v4/whats-trending/EEOC-2023-0004-0001"
    }
  }, {
    "id" : "FWS-HQ-ES-2023-0018-0001",
    "type" : "whats-trending",
    "attributes" : {
      "documentType" : "Proposed Rule",
      "agencyId" : "FWS",
      "commentEndDate" : "2023-08-22T03:59:59Z",
      "title" : "Endangered and Threatened Species: Regulations Pertaining to Endangered and Threatened Wildlife and Plants"
    },
    "links" : {
      "self" : "https://api.regulations.gov/v4/whats-trending/FWS-HQ-ES-2023-0018-0001"
    }
  }, {
    "id" : "FWS-HQ-ES-2021-0104-0001",
    "type" : "whats-trending",
    "attributes" : {
      "documentType" : "Proposed Rule",
      "agencyId" : "FWS",
      "commentEndDate" : "2023-08-22T03:59:59Z",
      "title" : "Endangered and Threatened Species: Interagency Cooperation"
    },
    "links" : {
      "self" : "https://api.regulations.gov/v4/whats-trending/FWS-HQ-ES-2021-0104-0001"
    }
  }, {
    "id" : "FWS-HQ-ES-2021-0107-0001",
    "type" : "whats-trending",
    "attributes" : {
      "documentType" : "Proposed Rule",
      "agencyId" : "FWS",
      "commentEndDate" : "2023-08-22T03:59:59Z",
      "title" : "Endangered and Threatened Species: Listing and Designating Critical Habitat"
    },
    "links" : {
      "self" : "https://api.regulations.gov/v4/whats-trending/FWS-HQ-ES-2021-0107-0001"
    }
  } ]
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值