I have a question for Python web crawling.

Asked 1 years ago, Updated 1 years ago, 118 views

Hi, everyone. I'm a beginner at Python. I would like to print out the equipment name and usage time on the equipment monitoring site using web crawling.

This code has been configured so far, and if you print it out like that, the strong tag and the lmis tag will be printed sequentially. IFIT16 These are equipment names and strong tags Numbers such as 1,320 are usage time Lmis tags. The type that I want to print out is to make it appear on the same line, like lFIT16, 1320. I would like to ask you about the parts that need to be modified and the parts that need to be added in the code you wrote. *Site HTML cannot be accessed outside due to security.

Also, in the case of usage time, I want to print things that are more than 1000 hours, so I tried using the if statement, but I failed, so I ask for advice.

I'm posting some sources and organizing the site to help.

IFIA10 1,320 It's represented like this. Help me

It's organized like this. I'd like to take out the blue underlined IFIA10 and LMIS usage time of 1,392. Only things that are over 1000 hours

python web-crawling for

2022-09-22 18:17

1 Answers

soup = beautifulsoup(html, 'html.parser')
for tb in soup.find_all("tr"):
    if tb.parent.name == 'tbody':
        print(tb.find('strong').text )
        print(tb.find('lmis').text )

How does it come out if I do this?

Also, you have to scratch the entire HTML so that I can tell you the exact problem.

I don't know which unique tag to bring just by looking at the picture.


2022-09-22 18:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.