Add a custom session support#228
Merged
python273 merged 1 commit intopython273:masterfrom Jul 6, 2019
sakost:master
Merged
Conversation
Owner
|
Это можно напрямую ставить vk_session = VkApi(...)
vk_session.http.proxies = {...} |
Contributor
Author
|
@python273 я так и делал в своих проектах, но считаю, что это, своего рода, костыли |
python273
reviewed
Feb 28, 2019
| :param session: Кастомная сессия со своими параметрами(из библиотеки requests) | ||
| :type session: :class:`requests.Session` | ||
|
|
||
| :param session_args: Аргументы для создания requests сессии(не используются, если была передана кастомная сессия) |
Owner
There was a problem hiding this comment.
Окей, давай оставим только session, а то session_args почти то же самое
Allow user to give a custom session object
Contributor
Author
|
Итак, я исправил. |
python273
reviewed
Mar 10, 2019
| @@ -1,4 +1,4 @@ | |||
| # -*- coding: utf-8 -*- | |||
| # -*- coding: utf-8 -*- | |||
| """ | |||
Owner
There was a problem hiding this comment.
Почему-то гитхаб изменение показывает. Возможно у тебя \r\n переносы, вроде должны быть \n
Contributor
Author
There was a problem hiding this comment.
В GitKraken такого нет...
|
+1 |
|
А можно какой-то пример кода, как передавать свои параметры в session из скрипта? |
Owner
import requests
import vk_api
session = requests.Session()
session.headers.update(...)
vk_session = vk_api.VkApi(..., session=session)
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Я думаю, что в vk_api не хватает явного указания proxy, headers, cookies и других параметров. Я сделал набросок кода, который будет устранять эту проблему. Надеюсь, что автор добавит это решение, т.к. лично мне в проектах уже какой раз требуется изобретать велосипед из-за того, что в данной библиотеке нет такой возможности по умолчанию.