Closed marshonhuckleberry closed 4 years ago
forgot to say, i use python 3.6
The pywebcopy uses a inbuilt requests
library session which stores the
headers and cookies and all other data during all the requests.
You can customize this session before start to modify the cookies or
headers etc.
import pywebcopy
pywebcopy.SESSION.cookies['cookie_key'] = 'some_id'
pywebcopy.config.setup_config('http://google.com', '/path/to/downloads/', debug=True)
pywebcopy.save_webpage('http://google.com')
You can learn more about manipulation of requests session from documentation.
what is this part of the code doing? pywebcopy.config.setup_config('http://google.com', '/path/to/downloads/', debug=True)
it looks like its the config but im confused why use url two times? pywebcopy.config.setup_config('http://google.com' pywebcopy.save_webpage('http://google.com')
The url
value in the pywebcopy.config.setup_config
is used for setup purposes.
The config handlers loads robots.txt
from this url and also it prepares the base path based roughly on the url where all the files will end up.
But in the second case the url is used to load page itself from the server.
So bottom line is they both are required. You should just store the url in a variable and just pass it twice.
from what i can understand from requests documentation and google is that there are two ways of using cookies:
and i forgot to say is not just complicated to set cookies in requests but is 1000 complicated to set cookies in pywebcopy
Cookies are automatically stores in the pywebcopy.SESSION attribute which is essentially a requests.Session() object. If you can do it on requests then you can do it on pywebcopy. There is absolutely no difference. Btw requests is a very well known library in Python . You can find hundreds of ways to authenticate through requests on stackoverflow.
On Fri, Jan 31, 2020, 5:39 PM marshonhuckleberry notifications@github.com wrote:
and i forgot to say is not just complicated to set cookies in requests but is 1000 complicated to set cookies in pywebcopy
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rajatomar788/pywebcopy/issues/30?email_source=notifications&email_token=AIGSNTS72EZ3MLZR32S5VLTRAQIFZA5CNFSM4KLGCIE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKOOSMI#issuecomment-580708657, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIGSNTWA6ZEU7L2ECQTQKNLRAQIFZANCNFSM4KLGCIEQ .
If you still have issue then use a third party library MechanicalSoup
for browser navigation and form filling in python then use that library session to set it as pywebcopy.SESSION
. It will be smooth.
I am now closing this issue if you have any further problems then you can always reopen this issue.
how to use cookies same as a browser would do, the cookies are saved automaticaly and no manual copy needed?