[Solved] Python – var = var = var value

Use a dictionary, not variables. If you have variable names, the way to get the variable contents is evil, and almost always there is a better way. In this case: server_connection_commands = { “AdminServer”: “putty.exe -ssh”, “Server1”: “putty.exe -ssh” } server = requests.get(‘http://example.com’).text subprocess.Popen(server_connection_commands[server]) 2 solved Python – var = var = var … Read more

[Solved] Problem with can only concatenate str (not “NoneType”) to str

The problem is, sizes doesn’t return anything. print does not return values, it just prints. You’d need to do something like: acc = “” for span in Size: acc += span.text.replace(‘EU:’,”).strip() # Concatenate the strings together return acc There are also more efficient ways of doing this using a list comprehension/generator expression and join: return … Read more

[Solved] Python urllib2 or requests post method [duplicate]

This is not the most straight forward post request, if you look in developer tools or firebug you can see the formdata from a successful browser post: All that is pretty straight forward bar the fact you see some : embedded in the keys which may be a bit confusing, simpleSearchSearchForm:commandSimpleFPSearch is the key and … Read more

[Solved] Unable to communicate with API

CONCLUSION – 07-25-2021 After looking at this problem in more detail, I believe that it is NOT technically possible to use Python Requests to scrape the website and table in your question. Which means that your question cannot be solved in the manner that you would prefer. Why? The website employs anti-scraping mechanisms. The GBK … Read more

[Solved] PlayerDB API Post Requests bring 404

If you are getting error messages from the API like this: {“message”: “”, “code”: “api.404”, “data”: {}, “success”: false, “error”: false} try requesting each UUID seperately and once you have gotten a good response, try running it with your program. It seems that the API caches UUIDs that have been asked for the first time, … Read more

[Solved] How to use python-request to post a file on a Rails App

I figured it out: def add_photo(entry_id, image_path): return requests.post( url = URL, headers = HEADER, files = { ‘entry[entry_id]’: (None, entry_id, ‘text’), ‘entry[photo]’: (os.path.basename(image_path), open(image_path, ‘rb’), ‘image/jpg’, {‘Expires’: ‘0’}) } ) solved How to use python-request to post a file on a Rails App

[Solved] Bad Request in Python

maybe this will help import requests city = input(“What is the name of the city?: “) url= “http://api.openweathermap.org/data/2.5/weather?q={city}&appid=*************”.format(city=city) response = requests.get(url) print(response) 2 solved Bad Request in Python

[Solved] Web scraping program cannot find element which I can see in the browser

The element you’re interested in is dynamically generated, after the initial page load, which means that your browser executed JavaScript, made other network requests, etc. in order to build the page. Requests is just an HTTP library, and as such will not do those things. You could use a tool like Selenium, or perhaps even … Read more

[Solved] Multi-tasking with Multiprocessing or Threading or Asyncio, depending on the Scenario

So off the top of my head you can look at 2 things. 1) Asyncio (be careful this example uses threading and is not thread safe specifically the function asyncio.gather) import asyncio for work in [1,2,3,4,5]: tasks.append(method_to_be_called(work)) results = await asyncio.gather(*tasks) 2) Asyncio + multiprocessing https://github.com/jreese/aiomultiprocess 1 solved Multi-tasking with Multiprocessing or Threading or Asyncio, … Read more

[Solved] What request should I make to get the followers list from a specific profile page

Try this: import time import requests link = ‘https://api-mainnet.rarible.com/marketplace/api/v4/followers’ params = {‘user’: ‘0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3’} payload = {“size”: 20} with requests.Session() as s: s.headers[‘User-Agent’] = ‘Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36’ res = s.post(link,params=params,json=payload) for item in res.json(): print(item[‘owner’][‘name’]) 1 solved What request should I make to get the followers list from a … Read more