Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python bs4最大结果长度_Python_Web Scraping_Beautifulsoup_Bs4 - Fatal编程技术网

Python bs4最大结果长度

Python bs4最大结果长度,python,web-scraping,beautifulsoup,bs4,Python,Web Scraping,Beautifulsoup,Bs4,我目前正在编写一个python脚本,用bs4来抓取一个新闻站点,我想在我的16x2 lcd屏幕上显示结果。有没有可能有一个最大长度的汤。找到所有的结果 from bs4 import BeautifulSoup from urllib.request import Request, urlopen import re r=urlopen("https://derstandard.at") url = "https://derstandard.at" soup = BeautifulSoup(

我目前正在编写一个python脚本,用bs4来抓取一个新闻站点,我想在我的16x2 lcd屏幕上显示结果。有没有可能有一个最大长度的汤。找到所有的结果

from bs4 import BeautifulSoup
from urllib.request import Request, urlopen
import re

r=urlopen("https://derstandard.at")
url = "https://derstandard.at"

soup = BeautifulSoup(r, "html.parser")

for a in soup.find_all("h2", limit=5):
    print(a.text)

这是当前的脚本

我怀疑在BeatifulSoup中是否有一种特殊的方法来实现这一点,而且您真的不需要

for a in soup.find_all("h2"):
    if len(a.text) <= 5:
        print(a.text)
查找汤中的所有(“h2”):

如果len(a.text)我不确定你在问什么,但如果以下问题没有回答,请告诉我

您正在寻找在大屏幕上显示输出(控制台)的方法。 现在,虽然我不确定如何处理这个问题,但您可能可以使用特定的IDE或更改控制台的模式,以便在大屏幕上显示

import os

os.system('mode con: cols=100 lines=40')
当然,您可以更改单位以显示更大或更宽的结果


如果您可以将问题编辑得更详细一点,或者发表评论说我的思路正确,这样我就可以帮助您,这将非常有用,谢谢。

请在问题中添加一个。您当前的代码有什么问题?