How to extract data from tags which are child of another tag through scrapy and python?

前端 未结 1 727
自闭症患者
自闭症患者 2021-01-29 06:50

This is the html code from which i want to extract data. But whenever i run i am getting some random values. Please can anyone help me out with this.

I want to extract t

1条回答
  •  清歌不尽
    2021-01-29 07:35

    Even though you haven't provided much detail that pertains to the issue at hand such as the output that you're getting or the website and question, I'm willing to put money that the problem is the Rangers that you put in your itemization...

    Is the return values that you say are random/incorrect come from when running spider... as in your crawling the sites entire directory of different ... institutes? meaning that the html snippet is just one of the many other pages your scrapping?? If so...

    Then your issue is for sure a range issue... your using ranges to select a tag from others in the same node... but what happens if the pages in the site are not all the same? Range remains the same but the position of you content does not so your going to get either none values.

    In the for loop..

    def parse(self, response):
        for students in response.css('div.topBlockInstituteInfoBottom'):
    

    The css value that your using I cannot verify if its correct due to the fact I dont know the site in question BUT taking the HTML snippet you showed... the css value in your loop is wrong...

    0 讨论(0)
提交回复
热议问题