【问题标题】:Exploring a website's Source code on Python and Text to Speech在 Python 和 Text to Speech 上探索网站的源代码
【发布时间】:2016-11-13 00:13:45
【问题描述】:

我是 python 和这个论坛的新手。我目前正在使用 PyCharm,并使用它来制作一个简单的代码,在屏幕上打印网站的源代码。我看了一段视频,代码是这样的:

import requests

from bs4 import BeautifulSoup4

url = "Google.com"
S = requests.get(url)
C = s.text
T = BeautifulSoup(C)

print(T)

现在我想从一个网站的源代码中读取一行,就像一个固定的确定的行,我应该怎么做?

另外,如何在 PyCharm 中的 Windows 上使用 pyttsx。我需要一个用于 python 的文本到语音引擎。

有什么方法可以在 python 上使用语音识别引擎。我的意思是像 Google 一样在线还是离线?

【问题讨论】:

  • 请向我们展示您到目前为止所做的尝试。
  • @Harsh8V Speech-recognition-api 标签适用于 iOS 10。仅供参考,以供将来使用该标签。

标签: python web text-to-speech speech-recognition-api


【解决方案1】:

我让它工作了。我猜这是一个错误... 我最后做了这个

import requests
len=20 #length of string u want to copy
Url="some random url"
T1=requests.get(Url)
T2=T1.content
Pos=T2.find("Search string")
String=T2[pos:pos+len]
print(String)

在我的原始项目中,字符串长度不确定,但我让它工作,通过使用 while 循环复制字符串,直到出现像 <p> 这样的结束注释。这也成功了。

我使用 VBScript 进行语音合成 并使用了谷歌语音识别。

【讨论】:

    猜你喜欢
    • 2017-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多