Links from list - How to generate several pdf's using python pdfkit2019 Community Moderator ElectionCreate PDF of a https webpage which requires login using pdfkitHow do I check if a list is empty?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Getting the last element of a list in PythonHow to make a flat list out of list of lists?How do I get the number of elements in a list in Python?How do I concatenate two lists in Python?How to clone or copy a list?How do I list all files of a directory?
Can other pieces capture a threatening piece and prevent a checkmate?
Symbolism of 18 Journeyers
Does fire aspect on a sword, destroy mob drops?
Is this Pascal's Matrix?
Hackerrank All Women's Codesprint 2019: Name the Product
If I cast the Enlarge/Reduce spell on an arrow, what weapon could it count as?
Turning a hard to access nut?
The English Debate
Have any astronauts/cosmonauts died in space?
Jem'Hadar, something strange about their life expectancy
Have the tides ever turned twice on any open problem?
Homology of the fiber
Output visual diagram of picture
Do people actually use the word "kaputt" in conversation?
What is it called when someone votes for an option that's not their first choice?
What happens when the centripetal force is equal and opposite to the centrifugal force?
Is there any common country to visit for uk and schengen visa?
Why do I have a large white artefact on the rendered image?
Why is this tree refusing to shed its dead leaves?
label a part of commutative diagram
How to balance a monster modification (zombie)?
Does the Shadow Magic sorcerer's Eyes of the Dark feature work on all Darkness spells or just his/her own?
Exposing a company lying about themselves in a tightly knit industry: Is my career at risk on the long run?
What are the consequences of changing the number of hours in a day?
Links from list - How to generate several pdf's using python pdfkit
2019 Community Moderator ElectionCreate PDF of a https webpage which requires login using pdfkitHow do I check if a list is empty?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Getting the last element of a list in PythonHow to make a flat list out of list of lists?How do I get the number of elements in a list in Python?How do I concatenate two lists in Python?How to clone or copy a list?How do I list all files of a directory?
I am currently trying to figure out how i can take a list of links and make python run through all of them and save them as pdf. (I'm not a python expert)
I found a python package called "pdfkit" which is quite good, but how do i set it up so that it follow my url-list and save the pdf as different names all the time?
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
pdfkit.from_url('http://google.com', 'MyPDF.pdf', configuration=config)
This is my current code, lets say that i have a list of 10 webpages that i want to save as 10 different pdf files how do i make a setup that would allow me to do so?
Another issue is that i need to login to the page in order to scrape the information from the links, how would you implement that?
Best Regards,
python list web pdfkit
add a comment |
I am currently trying to figure out how i can take a list of links and make python run through all of them and save them as pdf. (I'm not a python expert)
I found a python package called "pdfkit" which is quite good, but how do i set it up so that it follow my url-list and save the pdf as different names all the time?
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
pdfkit.from_url('http://google.com', 'MyPDF.pdf', configuration=config)
This is my current code, lets say that i have a list of 10 webpages that i want to save as 10 different pdf files how do i make a setup that would allow me to do so?
Another issue is that i need to login to the page in order to scrape the information from the links, how would you implement that?
Best Regards,
python list web pdfkit
add a comment |
I am currently trying to figure out how i can take a list of links and make python run through all of them and save them as pdf. (I'm not a python expert)
I found a python package called "pdfkit" which is quite good, but how do i set it up so that it follow my url-list and save the pdf as different names all the time?
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
pdfkit.from_url('http://google.com', 'MyPDF.pdf', configuration=config)
This is my current code, lets say that i have a list of 10 webpages that i want to save as 10 different pdf files how do i make a setup that would allow me to do so?
Another issue is that i need to login to the page in order to scrape the information from the links, how would you implement that?
Best Regards,
python list web pdfkit
I am currently trying to figure out how i can take a list of links and make python run through all of them and save them as pdf. (I'm not a python expert)
I found a python package called "pdfkit" which is quite good, but how do i set it up so that it follow my url-list and save the pdf as different names all the time?
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
pdfkit.from_url('http://google.com', 'MyPDF.pdf', configuration=config)
This is my current code, lets say that i have a list of 10 webpages that i want to save as 10 different pdf files how do i make a setup that would allow me to do so?
Another issue is that i need to login to the page in order to scrape the information from the links, how would you implement that?
Best Regards,
python list web pdfkit
python list web pdfkit
edited Mar 7 at 19:19
user1338133
asked Mar 7 at 19:04
user1338133user1338133
715
715
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Answer for the first question:
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
url_list = [
['http://google.com', 'google.com.pdf'],
['http://facebook.com', 'facebook.com.pdf'],
['http://yahoo.com', 'yahoo.com.pdf'],
]
for k, v in url_list:
pdfkit.from_url(k, v, configuration=config)
For answer to the second question, you can use the requests module session feature to login first and then pass the cookie to pdfkit to download the page. See Create PDF of a https webpage which requires login using pdfkit
Thank you for your reply, i went with another solution, but it keeps giving me an error saying the code follows below File "C:UsersJeppeAnaconda3libsite-packagespdfkitconfiguration.py", line 21, in init with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b''
– user1338133
Mar 9 at 8:12
I couldnt make it stick as code when posting comment so i posted the code below in the answer
– user1338133
Mar 9 at 8:19
Btw how do i implement the url_list that you created for me in the code down below?
– user1338133
Mar 9 at 8:26
add a comment |
import selenium.webdriver
import pdfkit
import time
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files
(x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
driver = selenium.webdriver.Chrome()
driver.get('https://www.linkedin.com/')
time.sleep(1)
driver.find_element_by_id('login-email').send_keys('username')
driver.find_element_by_id('login-password').send_keys('password')
driver.find_element_by_id('login-submit').click()
time.sleep(2)
driver.save_screenshot('output.png') # only visible part
print(driver.page_source)
pdfkit.from_string(driver.page_source, 'file.pdf')
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55051080%2flinks-from-list-how-to-generate-several-pdfs-using-python-pdfkit%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Answer for the first question:
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
url_list = [
['http://google.com', 'google.com.pdf'],
['http://facebook.com', 'facebook.com.pdf'],
['http://yahoo.com', 'yahoo.com.pdf'],
]
for k, v in url_list:
pdfkit.from_url(k, v, configuration=config)
For answer to the second question, you can use the requests module session feature to login first and then pass the cookie to pdfkit to download the page. See Create PDF of a https webpage which requires login using pdfkit
Thank you for your reply, i went with another solution, but it keeps giving me an error saying the code follows below File "C:UsersJeppeAnaconda3libsite-packagespdfkitconfiguration.py", line 21, in init with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b''
– user1338133
Mar 9 at 8:12
I couldnt make it stick as code when posting comment so i posted the code below in the answer
– user1338133
Mar 9 at 8:19
Btw how do i implement the url_list that you created for me in the code down below?
– user1338133
Mar 9 at 8:26
add a comment |
Answer for the first question:
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
url_list = [
['http://google.com', 'google.com.pdf'],
['http://facebook.com', 'facebook.com.pdf'],
['http://yahoo.com', 'yahoo.com.pdf'],
]
for k, v in url_list:
pdfkit.from_url(k, v, configuration=config)
For answer to the second question, you can use the requests module session feature to login first and then pass the cookie to pdfkit to download the page. See Create PDF of a https webpage which requires login using pdfkit
Thank you for your reply, i went with another solution, but it keeps giving me an error saying the code follows below File "C:UsersJeppeAnaconda3libsite-packagespdfkitconfiguration.py", line 21, in init with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b''
– user1338133
Mar 9 at 8:12
I couldnt make it stick as code when posting comment so i posted the code below in the answer
– user1338133
Mar 9 at 8:19
Btw how do i implement the url_list that you created for me in the code down below?
– user1338133
Mar 9 at 8:26
add a comment |
Answer for the first question:
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
url_list = [
['http://google.com', 'google.com.pdf'],
['http://facebook.com', 'facebook.com.pdf'],
['http://yahoo.com', 'yahoo.com.pdf'],
]
for k, v in url_list:
pdfkit.from_url(k, v, configuration=config)
For answer to the second question, you can use the requests module session feature to login first and then pass the cookie to pdfkit to download the page. See Create PDF of a https webpage which requires login using pdfkit
Answer for the first question:
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files (x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
url_list = [
['http://google.com', 'google.com.pdf'],
['http://facebook.com', 'facebook.com.pdf'],
['http://yahoo.com', 'yahoo.com.pdf'],
]
for k, v in url_list:
pdfkit.from_url(k, v, configuration=config)
For answer to the second question, you can use the requests module session feature to login first and then pass the cookie to pdfkit to download the page. See Create PDF of a https webpage which requires login using pdfkit
edited Mar 7 at 19:57
answered Mar 7 at 19:51
Thinh PhamThinh Pham
33416
33416
Thank you for your reply, i went with another solution, but it keeps giving me an error saying the code follows below File "C:UsersJeppeAnaconda3libsite-packagespdfkitconfiguration.py", line 21, in init with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b''
– user1338133
Mar 9 at 8:12
I couldnt make it stick as code when posting comment so i posted the code below in the answer
– user1338133
Mar 9 at 8:19
Btw how do i implement the url_list that you created for me in the code down below?
– user1338133
Mar 9 at 8:26
add a comment |
Thank you for your reply, i went with another solution, but it keeps giving me an error saying the code follows below File "C:UsersJeppeAnaconda3libsite-packagespdfkitconfiguration.py", line 21, in init with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b''
– user1338133
Mar 9 at 8:12
I couldnt make it stick as code when posting comment so i posted the code below in the answer
– user1338133
Mar 9 at 8:19
Btw how do i implement the url_list that you created for me in the code down below?
– user1338133
Mar 9 at 8:26
Thank you for your reply, i went with another solution, but it keeps giving me an error saying the code follows below File "C:UsersJeppeAnaconda3libsite-packagespdfkitconfiguration.py", line 21, in init with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b''
– user1338133
Mar 9 at 8:12
Thank you for your reply, i went with another solution, but it keeps giving me an error saying the code follows below File "C:UsersJeppeAnaconda3libsite-packagespdfkitconfiguration.py", line 21, in init with open(self.wkhtmltopdf) as f: FileNotFoundError: [Errno 2] No such file or directory: b''
– user1338133
Mar 9 at 8:12
I couldnt make it stick as code when posting comment so i posted the code below in the answer
– user1338133
Mar 9 at 8:19
I couldnt make it stick as code when posting comment so i posted the code below in the answer
– user1338133
Mar 9 at 8:19
Btw how do i implement the url_list that you created for me in the code down below?
– user1338133
Mar 9 at 8:26
Btw how do i implement the url_list that you created for me in the code down below?
– user1338133
Mar 9 at 8:26
add a comment |
import selenium.webdriver
import pdfkit
import time
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files
(x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
driver = selenium.webdriver.Chrome()
driver.get('https://www.linkedin.com/')
time.sleep(1)
driver.find_element_by_id('login-email').send_keys('username')
driver.find_element_by_id('login-password').send_keys('password')
driver.find_element_by_id('login-submit').click()
time.sleep(2)
driver.save_screenshot('output.png') # only visible part
print(driver.page_source)
pdfkit.from_string(driver.page_source, 'file.pdf')
add a comment |
import selenium.webdriver
import pdfkit
import time
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files
(x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
driver = selenium.webdriver.Chrome()
driver.get('https://www.linkedin.com/')
time.sleep(1)
driver.find_element_by_id('login-email').send_keys('username')
driver.find_element_by_id('login-password').send_keys('password')
driver.find_element_by_id('login-submit').click()
time.sleep(2)
driver.save_screenshot('output.png') # only visible part
print(driver.page_source)
pdfkit.from_string(driver.page_source, 'file.pdf')
add a comment |
import selenium.webdriver
import pdfkit
import time
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files
(x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
driver = selenium.webdriver.Chrome()
driver.get('https://www.linkedin.com/')
time.sleep(1)
driver.find_element_by_id('login-email').send_keys('username')
driver.find_element_by_id('login-password').send_keys('password')
driver.find_element_by_id('login-submit').click()
time.sleep(2)
driver.save_screenshot('output.png') # only visible part
print(driver.page_source)
pdfkit.from_string(driver.page_source, 'file.pdf')
import selenium.webdriver
import pdfkit
import time
config = pdfkit.configuration(wkhtmltopdf="C:\Program Files
(x86)\wkhtmltopdf\bin\wkhtmltopdf.exe")
driver = selenium.webdriver.Chrome()
driver.get('https://www.linkedin.com/')
time.sleep(1)
driver.find_element_by_id('login-email').send_keys('username')
driver.find_element_by_id('login-password').send_keys('password')
driver.find_element_by_id('login-submit').click()
time.sleep(2)
driver.save_screenshot('output.png') # only visible part
print(driver.page_source)
pdfkit.from_string(driver.page_source, 'file.pdf')
answered Mar 9 at 8:19
user1338133user1338133
715
715
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55051080%2flinks-from-list-how-to-generate-several-pdfs-using-python-pdfkit%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown