OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

I am learning Python code to scrape web pages for the first time, but why does it always fail to debug? There is no problem when running it in others

  • Thread starter Thread starter sysdemo
  • Start date Start date
S

sysdemo

Guest
this is my code:

Code:
import requests
import json

# datadome api on https://www.clearcaptcha.com 
clearcaptcha_api="http://api.clearcaptcha.com/captcha/datadome";
token = 'test'
uri = "https://www.idealista.com/"
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
proxy = "ip:port:username:password"

payload = {
    "token": token,
    "uri": uri,
    "user_agent": user_agent,
    "proxy": proxy
}

post_data=json.dumps(payload)
print(post_data)
response = requests.post(clearcaptcha_api, data=post_data)
if response.status_code == 200:
    response_data = response.json()
    print(response_data)
else:
    print({
        "error": "api error",
        "status_code": response.status_code,
        "response": response.text
    })
<p>this is my code:</p>
<pre><code>import requests
import json

# datadome api on https://www.clearcaptcha.com
clearcaptcha_api="http://api.clearcaptcha.com/captcha/datadome";
token = 'test'
uri = "https://www.idealista.com/"
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
proxy = "ip:port:username:password"

payload = {
"token": token,
"uri": uri,
"user_agent": user_agent,
"proxy": proxy
}

post_data=json.dumps(payload)
print(post_data)
response = requests.post(clearcaptcha_api, data=post_data)
if response.status_code == 200:
response_data = response.json()
print(response_data)
else:
print({
"error": "api error",
"status_code": response.status_code,
"response": response.text
})
</code></pre>
 

Latest posts

B
Replies
0
Views
1
Blundering Ecologist
B
Top