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?










0















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,










share|improve this question




























    0















    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,










    share|improve this question


























      0












      0








      0








      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,










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 19:19







      user1338133

















      asked Mar 7 at 19:04









      user1338133user1338133

      715




      715






















          2 Answers
          2






          active

          oldest

          votes


















          0














          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






          share|improve this answer

























          • 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


















          0














          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')





          share|improve this answer






















            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
            );



            );













            draft saved

            draft discarded


















            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









            0














            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






            share|improve this answer

























            • 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















            0














            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






            share|improve this answer

























            • 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













            0












            0








            0







            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






            share|improve this answer















            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







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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

















            • 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













            0














            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')





            share|improve this answer



























              0














              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')





              share|improve this answer

























                0












                0








                0







                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')





                share|improve this answer













                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')






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 9 at 8:19









                user1338133user1338133

                715




                715



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme