Proxy Endpoint
通过 Oxylabs 网页爬虫 API 的 Proxy Endpoint 发送和接收数据。通过基于 URL 的简单集成直接访问目标页面。
端点
GET realtime.oxylabs.io:60000输入
curl -k -x https://realtime.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
-H 'x-oxylabs-user-agent-type: desktop_chrome' \
-H 'x-oxylabs-geo-location: Germany' \
'https://www.example.com'import requests
from pprint import pprint
# 在此处使用您的 SERP API 凭据。
USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# 定义代理字典。
proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@realtime.oxylabs.io:60000',
'https': f'https://{USERNAME}:{PASSWORD}@realtime.oxylabs.io:60000'
}
# 若要设置特定的地理位置、User-Agent 或渲染 Javascript
# 需要将参数作为请求头发送。
headers = {
'x-oxylabs-user-agent-type': 'desktop_chrome',
'x-oxylabs-geo-location': 'Germany',
#'X-Oxylabs-Render': 'html', # 如果您希望在页面内渲染 JavaScript,请取消注释。
}
response = requests.request(
'GET',
'https://www.example.com',
headers = headers, # 传入已定义的头部。
verify=False, # 接受我们的证书。
proxies=proxies,
)
# 将结果页面打印到 stdout。
pprint(response.text)
# 将返回的 HTML 保存到 'result.html' 文件中。
with open('result.html', 'w') as f:
f.write(response.text)输出
接受的参数
参数
说明
最后更新于
这有帮助吗?

