1

Given a dataframe df as follows:

             projectCode                                                url
0  FCZZZZCQ2021020200921  https://www.cspea.com.cn/list/c01/FCZZZZCQ2021020200921
1        GR2021BJ1000351  https://www.cspea.com.cn/list/c01/GR2021BJ1000351
2        GR2021QD1000030  https://www.cspea.com.cn/list/c01/GR2021QD1000030
3        GR2021BJ1000186  https://www.cspea.com.cn/list/c01/GR2021BJ1000186
4    FCZZCQ2020123011487  https://www.cspea.com.cn/list/c01/FCZZCQ2020123011487

I want to use pdfkit package save each url link as pdf file, and use projectCode as file name:

import pdfkit
import pandas as pd

data = []
urls =  df.url.tolist()
for url_link in urls:
    pdfkit.from_url(url, 'out.pdf')

How could I do that? Thanks.

3
  • is you are reading from pdf file or csv file just want to confirm Commented Apr 9, 2021 at 4:02
  • also how you created dataframe please do insert that code also so it will help solving issue fast Commented Apr 9, 2021 at 4:03
  • I read from xlsx format excel file @M_x Commented Apr 9, 2021 at 4:44

1 Answer 1

1

You should zip the columns to use it:

for a, url in zip(df['projectCode'], df['url']):
    pdfkit.from_url(url, f'{a}.pdf')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.