cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level IX

How can the download of this be completed?

The original data captured in the F12 browser

curl ^"https://cn.govopendata.com/xinwenlianbo/20250422/^" ^
  -H ^"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^" ^
  -H ^"accept-language: zh-CN,zh;q=0.9^" ^
  -H ^"cache-control: max-age=0^" ^
  -b ^"csrftoken=pNwjIMIrOOrnBe4GHTApOViIeNRBWwtI; _ga=GA1.1.239242113.1753140858; FCNEC=^%^5B^%^5B^%^22AKsRol_7sr_jz8BXh0YeUEUR5mSy1qL4wfsfs9XfmUOOzlIdLMJvsfgol4pcXisr7VbaTJZwRTrVSw8GGMEaAamWDh9LSXIxXj9O5k3V0EkilBGqe15w6DSZ4BceMdE4r1jUJZWTKbEm3STkdLujOfq755fcOqJP5A^%^3D^%^3D^%^22^%^5D^%^5D; _clck=1wdxmr4^%^7C2^%^7Cfxt^%^7C0^%^7C2029; _ga_7NESVRSV0K=GS2.1.s1753185097^$o3^$g1^$t1753186048^$j60^$l0^$h0; _clsk=nb3rgu^%^7C1753186048890^%^7C5^%^7C1^%^7Cv.clarity.ms^%^2Fcollect; __gads=ID=335a8fb772d726f1:T=1753140847:RT=1753186047:S=ALNI_MYKyblOPT3WE9PIgjHdPtYlQdN2wQ; __gpi=UID=0000116b9b56a5c8:T=1753140847:RT=1753186047:S=ALNI_Mb_sdW8WlGVmWp2SQ0U3v9G7fppFg; __eoi=ID=f8abc10bf0356803:T=1753140847:RT=1753186047:S=AA-Afjazt5ToEHQpkDn9PtsRpGnn^" ^
  -H ^"priority: u=0, i^" ^
  -H ^"referer: https://cn.govopendata.com/xinwenlianbo/?page=13^" ^
  -H ^"sec-ch-ua: ^\^"Not)A;Brand^\^";v=^\^"8^\^", ^\^"Chromium^\^";v=^\^"138^\^", ^\^"Google Chrome^\^";v=^\^"138^\^"^" ^
  -H ^"sec-ch-ua-mobile: ?0^" ^
  -H ^"sec-ch-ua-platform: ^\^"Windows^\^"^" ^
  -H ^"sec-fetch-dest: document^" ^
  -H ^"sec-fetch-mode: navigate^" ^
  -H ^"sec-fetch-site: same-origin^" ^
  -H ^"sec-fetch-user: ?1^" ^
  -H ^"upgrade-insecure-requests: 1^" ^
  -H ^"user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36^"

python code modified by AI:

import requests
from pathlib import Path

url = "https://cn.govopendata.com/xinwenlianbo/20250721/"

headers = {
    "sec-ch-ua": '"Not A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"',
    "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",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "max-age=0",
    "referer": "https://cn.govopendata.com/xinwenlianbo/20250721/",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": '"Windows"',
    "sec-fetch-dest": "document",
    "sec-fetch-mode": "navigate",
    "sec-fetch-site": "same-origin",
    "sec-fetch-user": "?1",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"
}
cookies = {
    "csrftoken": "pNwjIMIrOOrnBe4GHTApOViIeNRBWwtI",
    "__gads": "ID=335a8fb772d726f1:T=1753140847:RT=1753140847:S=ALNI_MYKyblOPT3WE9PIgjHdPtYlQdN2wQ",
    "__gpi": "UID=0000116b9b56a5c8:T=1753140847:RT=1753140847:S=ALNI_Mb_sdW8WlGVmWp2SQ0U3v9G7fppFg",
    "__eoi": "ID=f8abc10bf0356803:T=1753140847:RT=1753140847:S=AA-Afjazt5ToEHQpkDn9PtsRpGnn",
    "_ga": "GA1.1.239242113.1753140858",
    "FCNEC": '[[\"AKsRol_lyJVKvuPII10tMMWp3m_gh6UZiJ9Iej1Qg7VnR8bSTCnrLKTYNiQpPvEtsQkWDDlJCXxFJLurwTgZhoOiDfPe8XWxbQiQxlkfi3r7qGSPUlSTQyiBCTOpkIxy1RVLbQtVFHCYXz9FGzaWXlOp1l-wGib7Gg==\"]]',
    "_ga_7NESVRSV0K": "GS2.1.s1753140857$o1$g1$t1753140966$j39$l0$h0"
}

with requests.Session() as s:
    resp = s.get(url, headers=headers, cookies=cookies, timeout=10)
    resp.raise_for_status()         
    resp.encoding = resp.apparent_encoding  
    Path("xinwenlianbo_20250721.html").write_text(resp.text, encoding="utf-8")
11 REPLIES 11

回复: How can the download of this be completed?

Headers can be either.

If it's an associative array, it does the

key: value

for you.

But since the keys don't have to be unique in a header argument, you can also use a list with the

key: value

as an item in the list.

lala
Level IX

回复: How can the download of this be completed?

But this website address can be opened in a browser

Recommended Articles