Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have got proxies from leafproxies, and they are giving me something like this. I don't really understand what this is. At the very end, I want to use it in requests.
Here's what they provide.
ipaddress:port:xxx:xxx
I believe that xxx:xxx part is username and password but I am not really sure.
Can anyone guide me, how can I use it with python requests?
You can try this :
import requests
import os
#Syntax is http://username:password#ipaddress:port
http_proxyf = 'http://xxx:xxx#gPtYMLoPX84.5.maxrainbow.net:8877'
# Copy xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-au-xxxxxxxxxxxxxxxxx-xxxxxxxxxx:xxxxxxxxxxxx
# and paste at first
os.environ["http_proxy"] = http_proxyf
os.environ["https_proxy"] = http_proxyf
page=requests.get("https://google.com")
To check you can do this:
print(requests.get('https://api64.ipify.org?format=json').json())
This will return the ip address.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
i use atom editor for my python. i am self learning how to code with this book i bought. i am at loops now and when i put this code ,the code doesn't work:
Names = ["joy", "darwin", "jake"]
for name in Names:
print(f"{name.title()}, Hi!")
i have tried multiple things to try to make it work and none have worked so far
i don't know why because when my friends tried it in their editors it worked fine. Is there a certain package i have to download or something??? pls i need help
Try fixing your indentation:
Names = ["joy", "darwin", "jake"]
for name in Names:
print(f"{name.title()}, Hi!")
If this doesn't work, try changing editors.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I want a function which should run with or without a parameter.
This is my views.py
#api_view(['GET', 'POST'])
def enable_boards(request, board_ids=None):
```
This is my urls.py
path('enable_boards', views.enable_boards)
path('enable_boards/<str:boards_ids>', views.enable_boards)
Now I know I have to write re_path but I don't know how to write regex for this particular case. What should be the proper url in this case ?
Use url parameters instead of using it in the path.
For eg: https://127.0.0.1:8000/enable_boards?board_ids=[1,2,3]
And in view use: board_ids = request.GET.get('board_ids') for GET request and board_ids = request.data.get('board_ids') for POST request.
Happy coding
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm currently working on a small side project using the steam api, I want to check if the user inputs an url or not.
Could not find anything to this specific problem so if anyone knows that help!
Use regex
Sample Code Below:
import re
regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\"., <>?«»“”‘’]))"
def is_url(input_string):
return re.match(regex, input_string):
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
in my understanding, source in R is import and execute the code from source code. does Python has the equivalent function to import and execute.
Yes, you can import code/modules/etc using import in python. Here are some resources to get you started:
https://medium.com/code-85/a-beginners-guide-to-importing-in-python-bb3adbbacc2b
https://en.wikibooks.org/wiki/A_Beginner%27s_Python_Tutorial/Importing_Moduleshttps://en.wikibooks.org/wiki/A_Beginner%27s_Python_Tutorial/Importing_Modules
https://developers.google.com/edu/python/introduction
(If you know what you're doing, you may actually be looking for exec(open('filename').read()))
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
When i extract a url, it displays as below
https://tv.line.me/v/14985624_%E0%B8%A0%E0%B8%B9%E0%B8%95%E0%B8%A3%E0%B8%B1%E0%B8%95%E0%B8%95%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A5-ep3-6-6-%E0%B8%8A%E0%B9%88%E0%B8%AD%E0%B8%878
how do i convert this to more readable format like below in python. The link below is the same as above.
Link to the image of how the url appears on browser address bar
You can use urllib module to decode this url
from urllib.parse import unquote
url = unquote('https://tv.line.me/v/14985624_%E0%B8%A0%E0%B8%B9%E0%B8%95%E0%B8%A3%E0%B8%B1%E0%B8%95%E0%B8%95%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A5-ep3-6-6-%E0%B8%8A%E0%B9%88%E0%B8%AD%E0%B8%878')
print(url)
This will give you the result as follows.
https://tv.line.me/v/14985624_ภูตรัตติกาล-ep3-6-6-ช่อง8
Thank you