跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • Python + selenium 也获取不了这个网页的源码
未分類
8 6 月 2020

Python + selenium 也获取不了这个网页的源码

Python + selenium 也获取不了这个网页的源码

資深大佬 : DonnyChao 8

最近有个网页整体翻译的需求,看了一下,Google 网页翻译是最优解,但是使用 selenium 也获取不了网页翻译后的源码。

网页对象链接( Google 网页翻译页面): https://translate.google.com.hk/translate?hl=&sl=en&tl=zh-CN&u=https://docs.python.org/3/tutorial/index.html

使用 selenium 取这个网页的源码,但是只能获取到 head 源码,body 主要的信息获取不到,请问有什么方法能获取到整个页面的源码吗?

[img]https://p.pstatp.com/origin/ff450002d304a982cd55[/img]

大佬有話說 (11)

  • 主 資深大佬 : DonnyChao

    ![image.png]( https://p.pstatp.com/origin/ff450002d304a982cd55)

  • 資深大佬 : noqwerty

    Google 的 Cloud Translation 可以直接调 API 的: https://cloud.google.com/translate/docs/

  • 資深大佬 : laoyur

    处理 iframe 时,要先 driver.switch_to.frame(frames[0])一下才行

  • 資深大佬 : 9yu

    检查有没有 iframe

  • 資深大佬 : xiri

    为什么不直接调用 API

  • 資深大佬 : jizhihaoSAMA

    iframe 正解

  • 主 資深大佬 : DonnyChao

    @laoyur
    @9yu

    是 iframe 原因,已按 3 方法解决。

  • 主 資深大佬 : DonnyChao

    @xiri Google 翻译 API 看网上教程说,不能翻译 HTML 文件,只能翻译文本

  • 資深大佬 : sxd96

    如果只是这个网页的话,你知不知道这有中文选项…

  • 資深大佬 : polarpy

    正解

  • 資深大佬 : yucongo

    用 Pyppeteer 吧,还能异步操作。有现成的基于 Pyppeteer 的包 https://pypi.org/project/deepl-tr-async/ pip install deepl-tr-async,可异步调 google 翻译或 deepl

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具