match_records = soup.find_all('td',class_ = 'rankings-block__banner--matches')
match_records
records = []
for i in match_records:
records.append(i.text)
records
match_records2 = soup.find_all('td',class_ = 'table-body__cell u-center-text')
match_records2
for i in match_records2:
records.append(i.text)
print(records)
输出:-
['17', '32', '3,793', '28', '3,244', '32', '3,624', '25', '2,459', '27', '2,524', '30', '2,740', '30', '2,523', '32', '2,657', '17', '1,054', '7', '336', '25', '1,145', '11', '435', '20', '764', '7', '258', '11', '330', '9', '190', '14', '232', '6', '97', '9', '0']
在
lambda
表达式和filter
的帮助下,您可以很容易地做到这一点你还需要绳子吗
在代码的末尾,变量
records
包含字符串列表您可以在填充列表时添加“if”语句,以确保只包含50多个值,也可以在填充列表后分析列表
注意
str
和int
对象之间的区别,注意逗号,
(请参见1234),您需要去掉它们我将在您的代码之后添加以下代码段:
这将创建通缉名单。 请注意,这并不是最有效的(内存+时间),但它易于使用和理解
使用
if
语句:和海象接线员联系。如果您的Python版本低于3.8,请使用:
相关问题 更多 >
编程相关推荐