def from_string(input, output_path, options=None, toc=None, cover=None, css=None,configuration=None, cover_first=False)
Configuration:Configuration中传入了wkhtmltopdf参数
https://blog.youkuaiyun.com/xc_zhou/article/details/80952168
指定pdf的格式
我们可以指定各种选项,就是上面三个方法中的options。
具体的设置可以参考https://wkhtmltopdf.org/usage/wkhtmltopdf.txt
里面的内容。
我们这里只举个栗子:
options = {
‘page-size’: ‘Letter’,
‘margin-top’: ‘0.75in’,
‘margin-right’: ‘0.75in’,
‘margin-bottom’: ‘0.75in’,
‘margin-left’: ‘0.75in’,
‘encoding’: “UTF-8”,
‘custom-header’ : [
(‘Accept-Encoding’, ‘gzip’)
]
‘cookie’: [
(‘cookie-name1’, ‘cookie-value1’),
(‘cookie-name2’, ‘cookie-value2’),
],
‘no-outline’: None
}
pdfkit.from_url(‘http://google.com’, ‘out.pdf’, options=options)
selenium_page.py
import re
import requests
def get_songid():
“”“获取音乐的songid”“”
url = ‘http://music.taihe.com/artist/2517’
response