2017-12-07 1 views
0

나는 HTML을 스크랩하고 어려운 도전을하기 위해 beautifulsoup을 배우려고 노력하고있다. .. 내가 스크랩에 노력하고 HTML을 잘 포맷되지 않고 BeautifulSoup로와 지식의 부족에 나는 가지 붙어파이썬으로 BeautifulSoup

내가 스크랩 애 쓰고 HTML 그래서

*<tr class="unique"> 
        <td>S.N.</td> 
        <td><a href="http://www.nepalstock.com/main/todays_price/index/1/stock-name/desc/" class="icon-asc sorter">Traded Companies</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/transaction/asc/" class="icon-sorter sorter">No. Of Transaction</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/max-price/asc/" class="icon-sorter sorter">Max Price</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/min-price/asc/" class="icon-sorter sorter">Min Price</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/closing-price/asc/" class="icon-sorter sorter">Closing Price</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/total-share/asc/" class="icon-sorter sorter">Traded Shares</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/amount/asc/" class="icon-sorter sorter">Amount</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/previous-closing/asc/" class="icon-sorter sorter">Previous Closing</a></td> 
        <td class="alnright"><a href="http://www.nepalstock.com/main/todays_price/index/1/difference/asc/" class="icon-sorter sorter">Difference Rs.</a></td> 
       </tr> 
       <tr> 
        <td>1</td> 
        <td>Agriculture Development Bank Limited</td> 
        <td class="alnright">47</td> 
        <td class="alnright">437.00</td> 
        <td class="alnright">426.00</td> 
        <td class="alnright">435.00</td> 
        <td class="alnright">9725.00</td> 
        <td class="alnright">4204614.00</td> 
        <td class="alnright">431.00</td> 
        <td class="alnright">4.00&nbsp; 
         <img src="http://www.nepalstock.com/images/increase.gif"> 
        </td> 
       </tr>* 

내가 원하는 결과 다음과 같다 얻을 수있는 문자열은 "Agriculture Development Bank Limited"입니다. 미리 도움을 주셔서 감사합니다!

+0

코드 및 귀하가 긁어 모으려는 URL을 게시하십시오. –

+0

현재 이건'soup.find_all ('tr') [1] .find_all ('td') [1] .text.strip()' –

+0

이 URL에서 긁어 모으려고합니다. 모든 무역 회사 목록. nepalstock.com/todaysprice. - bijay subedi @SagunShrestha –

답변

0

당신이 찾고있는 것이 무엇인지 일반적으로 묻는다면 더 정확하게 당신을 도울 수 있습니다. 이 필요를 충족시키는 코드는 다음과 같습니다.

from bs4 import BeautifulSoup 
html_doc = """ 
Your HTML code 
""" 
soup = BeautifulSoup(html_doc, 'html.parser') 
soup.find("td", text="Agriculture Development Bank Limited").text