Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url中携带#号的时候会生成不了pdf #147

Open
JiavLee opened this issue Feb 21, 2024 · 1 comment
Open

url中携带#号的时候会生成不了pdf #147

JiavLee opened this issue Feb 21, 2024 · 1 comment

Comments

@JiavLee
Copy link

JiavLee commented Feb 21, 2024

使用demo 跑这个baidu.com没有问题
这个地址不行
https://ysotmain.ysclass.net/zhxy/#/redirect/login

@JiavLee
Copy link
Author

JiavLee commented Feb 21, 2024

public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { //自动下载,第一次下载后不会再下载 // BrowserFetcher.downloadIfNotExist(null); ArrayList<String> arrayList = new ArrayList<>(); //生成pdf必须在无头模式下才能生效 LaunchOptions options = new LaunchOptionsBuilder().withArgs(arrayList).withHeadless(true).build(); options.setExecutablePath("D:\\workSoftware\\chrome-win\\chrome.exe"); arrayList.add("--no-sandbox"); arrayList.add("--disable-setuid-sandbox"); Browser browser = Puppeteer.launch(options); Page page = browser.newPage(); HashMap<String, String> map = Maps.newHashMap(); map.put("Authorization","Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcGVuQWNjb3VudElkIjoiOTUwNzI2OTI4MTg3NTMxMjY0IiwidGVuYW50SWQiOiI2Nzk3NzczMzk3MjIzMDU1MzYiLCJwbGF0Zm9ybVR5cGUiOiJwYyIsImlkIjoiOTUwNzI2OTI4MzM0MzMxOTA1Iiwib3BlblVzZXJJbmZvSWQiOiI5NTA1MDcwNjYyMjM2Mjk5MjkiLCJ1c2VyTmFtZSI6IjEzNjUwNzA4MzUzIiwiZXhwIjoxNzExMDQ0MDAwLCJvcmdJZCI6IjY3OTY3NTc4MzA3NzMwNDUxNCIsInVzZXJJbmZvSWQiOiI5NTA3MjY5MjgzMzQzMzE5MDQiLCJjcmVhdGVUaW1lc3RhbXAiOiIxNzA4NTAyMzU1MjIyIn0.Fz1Yk4ErfWgnNS2WFrF-FIpZOVKNg3MxGTesu_sLiJs"); map.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"); page.setExtraHTTPHeaders(map); page.goTo("https://ysotmain.ysclass.net/zhxy/#/redirect/login"); PDFOptions pdfOptions = new PDFOptions(); pdfOptions.setPath("testA2233.pdf"); page.pdf(pdfOptions); page.close(); browser.close(); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant