英文:
How do you access pass protected pastebin with python?
问题
我正在尝试从一个Pastebin链接运行Python脚本,但我想要Pastebin受到密码保护。这是我得到的全部:
import requests
pastebin_raw_link = 'https://pastebin.com/raw/F4adqxBq'
response = requests.get(pastebin_raw_link)
source_code = response.content
exec(source_code.decode('utf-8'))
英文:
Im trying to run a python script from a pastebin link but I wanna have the pastebin be password protected this is all I got
import requests
pastebin_raw_link = 'https://pastebin.com/raw/F4adqxBq'
response = requests.get(pastebin_raw_link)
source_code = response.content
exec(source_code.decode('utf-8'))
答案1
得分: 1
你可以使用开发者的 API 来访问私人粘贴,如此处所述:链接:
curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_key=YOUR API USER KEY' -d 'api_option=show_paste' -d 'api_paste_key=API PASTE KEY' "https://pastebin.com/api/api_post.php"
上面是一个示例的 POST 请求,你需要使用 Python 执行,使用以下参数:
api_dev_key
- 这是你的 API 开发者密钥,你可以通过登录到 pastebin来获取它。api_user_key
- 这是已登录用户的会话密钥。api_paste_key
- 这是你想要从中获取数据的粘贴密钥。api_option
- 设置为 'show_paste'(无需更改)。
现在你可以获取上述所有内容,除了 api_user_key
会话密钥。要获取会话密钥,你需要在调用此 API 之前调用另一个 API,如此处所述。以下是你需要转换为 Python 的示例 POST 请求:
curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_name=a_users_username' -d 'api_user_password=a_users_password' "https://pastebin.com/api/api_login.php"
使用以下参数:
api_dev_key
- 这是你的 API 开发者密钥。api_user_name
- 这是你想要登录的用户的用户名。api_user_password
- 这是你想要登录的用户的密码。
英文:
You can use developer's api to access private pastes as mentioned here:
curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_key=YOUR API USER KEY' -d 'api_option=show_paste' -d 'api_paste_key=API PASTE KEY' "https://pastebin.com/api/api_post.php"
The above is a sample POST request which you need to perform using python with the following parameters:
api_dev_key
- this is your API Developer Key, which you can obtain by logging into the pastebinapi_user_key
- this is the session key of the logged in userapi_paste_key
- this is paste key you want to fetch the data from.api_option
- set as 'show_paste' (No need to change)
Now you can get all the above except the api_user_key
session key. To get session key you need to call another API before this API as mentioned here. The following is the sample POST request which you need to convert into python:
curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_name=a_users_username' -d 'api_user_password=a_users_password' "https://pastebin.com/api/api_login.php"
with the parameters:
api_dev_key
- this is your API Developer Keyapi_user_name
- this is the username of the user you want to login.api_user_password
- this is the password of the user you want to login.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论