简体   繁体   English

来自 HTML 的 Python 请求返回空白?

[英]Python requests from HTML are returning blanks?

New to programming and trying to learn Python using ATBS and the web. I am running into the issue when I send requests, I get blanks in return?编程新手并尝试使用 ATBS 和 web 学习 Python。我在发送请求时遇到了问题,我得到的回报是空白? I asked Reddit and even download the file as a.txt file in which I found two mentions of the number I was trying to find.我问了 Reddit,甚至将文件下载为 .txt 文件,我在其中发现了两次提到我试图找到的号码。 But the CSS path selector that I am obtaining is outputting []?但是我正在获取的 CSS 路径选择器正在输出 []? I am finding other mention of the number via HTML but not the section of the html I am after.我通过 HTML 找到了该号码的其他提及,但不是我所关注的 html 的部分。

Questions:问题:

  1. Am I meant to copy using the CCS selector or CSS path?我是要使用 CCS 选择器还是 CSS 路径进行复制?

Code source and website html images: [1]: https://i.stack.imgur.com/ABIq0.png [2]: https://i.stack.imgur.com/3I109.png代码源和网站 html 图片:[1]: https://i.stack.imgur.com/ABIq0.png [2]: https://i.stack.imgur.com/3I109.png

Thanks.谢谢。

Here is the website from which I am trying to get the stock price number from: https://www.nzx.com/instruments/WBC also tried getting it from google, but had not luck: https://www.google.co.nz/search?q=westpac+nz+share+price&iflsig=AJiK0e8AAAAAYyxCN7k8VlOKPGk8EhszcUZWbOuzsBM4&ved=0ahUKEwjNkKj2k6j6AhWNDt4KHUPcD8sQ4dUDCAg&uact=5&oq=westpac+nz+share+price&sclient=gws-wiz这是我试图从中获取股票价格的网站: https://www.nzx.com/instruments/WBC也尝试从谷歌获取它,但运气不好: https://www.google。 co.nz/search?q=westpac+nz+share+price&iflsig=AJiK0e8AAAAAYyxCN7k8VlOKPGk8EhszcUZWbOuzsBM4&ved=0ahUKEwjNkKj2k6j6AhWNDt4KHUPcD8sQ4dUDCAg&uact=5&oq=westpac+nz+share+price&sclient=gws-wiz

In firefox copy CSS selector not CSS path.在 firefox 复制 CSS 选择器而不是 CSS 路径。 As mentioned in the video, I just happened to overlook it.正如视频中提到的,我只是碰巧忽略了它。 Using CSS selector I was able to get the answer I was after.使用 CSS 选择器我能够得到我想要的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM