[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 1.1.1.1”, “Server1”: “putty.exe -ssh 2.2.2.2” } 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