jsoup document select is not returning any values even when correct CSS selector is used from chrome dev tool

Viewed 25

I'm not understanding why below is returning 0 instead of 1 ?

I've taken below CSS Selector from Chrome dev tool itself.

doc.select("#company-holding_table > tbody > tr:nth-child(1) > td.table-text.dtfc-fixed-left > div > a")

https://www.valueresearchonline.com/funds/26123/motilal-oswal-flexi-cap-fund-regular-plan#fund-portfolio

I couldn't post complete HTML as character limit was exceeded.

     <div id="\&quot;protfolio_pie_chart1\&quot;" class="\&quot;d-flex" justify-content-center\ data-is-loaded="\&quot;false\&quot;">
                              &lt;\/div&gt;\r\n &lt;\/div&gt;\r\n &lt;\/div&gt;\r\n &lt;\/div&gt;\r\n &lt;\/div&gt;\r\n <!-- COMPANY HOLDING WRAPPER -->\r\n 
                              <div class="\&quot;company-holdings-wrapper" top-holding-table p-t-b-50 pb-0\>
                              \r\n 
                              <h2 class="\&quot;portfolio-tab-title\&quot;">\r\n Top Holdings &lt;\/h2&gt;\r\n <div\r\n class="\&quot;custom-table-wrapper" custom-table-wrapper__portfolio-holding-table custom-table-wrapper__section-table custom-table-wrapper__portfolio-holding-bottom-table with-borders pt-0 pb-0 pl-0 pr-0\>
                              \r\n 
                              <table id="\&quot;company-holding_table\&quot;" class="\&quot;table\&quot;">
                              \r\n 
                              <thead>
                              \r\n 
                              <tr class="\&quot;custom-header\&quot;" role="\&quot;row\&quot;">
                              \r\n 
                              <th class="\&quot;col-hide-mob" mobile-first-th\>\r\n 
                              <div class="\&quot;first-col-custom-width\&quot;">
                              \r\n Company Name &lt;\/div&gt;\r\n &lt;\/th&gt;\r\n
                              </div></th>
                              <th>\r\n 
                              <div class="\&quot;fixed-width-cell" fixed-width-cell-mob\>
                              \r\n Sector&lt;\/div&gt;\r\n &lt;\/th&gt;\r\n
                              </div></th>
                              <th class="\&quot;small-th-pr" text-right\>\r\n 
                              <div class="\&quot;fixed-width-cell" fixed-width-cell-mob\>
                              \r\n P\/E Ratio\r\n <img class="\&quot;info-icon" ml-2\ src="\&quot;\/asts\/img\/icons\/Info-icon.svg\&quot;\r\n" alt="\&quot;info\&quot;" tabindex="\&quot;0\&quot;" data-trigger="\&quot;focus\&quot;" data-toggle="\&quot;popover\&quot;" data-container="\&quot;body\&quot;\r\n" data-content="\&quot;<p">A valuation metric which indicates the price you pay for each rupee of a company's profits. It is calculated by dividing the current share price by earnings per share in the last 4 calendar quarters.&lt;\/p&gt;\"\r\n data-original-title=\"\" title=\"\" \/&gt;\r\n &lt;\/div&gt;\r\n &lt;\/th&gt;\r\n
                              </div></th>
                              <th class="\&quot;text-right\&quot;">\r\n 
                              <div class="\&quot;fixed-width-cell" fixed-width-cell-mob\>
                              \r\n % Assets <img class="\&quot;info-icon" ml-2\ src="\&quot;\/asts\/img\/icons\/Info-icon.svg\&quot;\r\n" alt="\&quot;info\&quot;" tabindex="\&quot;0\&quot;" data-trigger="\&quot;focus\&quot;" data-toggle="\&quot;popover\&quot;" data-container="\&quot;body\&quot;\r\n" data-content="\&quot;<p">The current weight of the security in the portfolio as a percentage of the fund's total assets.&lt;\/p&gt;\"\r\n data-original-title=\"\" title=\"\" \/&gt;\r\n &lt;\/div&gt;\r\n &lt;\/th&gt;\r\n
                              </div></th>
                              <th class="\&quot;no-sort" text-center\>\r\n <div\r\n class="\&quot;fixed-width-cell" fixed-width-cell-mob w-200 head-center\>
                              \r\n Holding Trend 
                              <a href="\&quot;\/premium\/subscribe\/?utm_medium=vro&amp;utm_campaign=premium-unlock&amp;utm_source=fund-details\&quot;">\r\n 
                              <div class="\&quot;unlock-premium" w-70\>
                              \r\n <img src="\&quot;\/asts\/img\/icons\/premium-lock.svg\&quot;\r\n" alt="\&quot;unlock" premium\ width="\&quot;20\&quot;" data-toggle="\&quot;tooltip\&quot;\r\n" data-placement="\&quot;top\&quot;" tabindex="\&quot;0\&quot;" data-html="\&quot;true\&quot;\r\n" title="\&quot;<p">Unlock with Premium&lt;\/p&gt;\"\r\n data-template=\"
                              <div class="tooltip unlock-premium-tooltip" role="tooltip">
                              <div class="arrow">
                              &lt;\/div&gt;
                              <div class="tooltip-inner">
                              &lt;\/div&gt;&lt;\/div&gt;\" \/&gt;\r\n &lt;\/div&gt;\r\n &lt;\/a&gt;\r\n &lt;\/div&gt;\r\n &lt;\/th&gt;\r\n &lt;\/tr&gt;\r\n &lt;\/thead&gt;\r\n
                              </div>
                              </div>
                              </div>
                              </div></a>
                              </div\r\n></th>
                              </tr>
                              </thead>
                              <tbody>
                              \r\n 
                              <tr>
                              \r\n 
                              <td class="\&quot;table-text\&quot;">\r\n 
                              <div class="\&quot;first-col-custom-width\&quot;">
                              \r\n <img src="\/asts\/img\/equalarrow.gif" width="12" height="8" alt="equal"> <a class="\&quot;custom-fund-name\&quot;\r\n" href="\&quot;\/stocks\/42383\/hdfc-bank-ltd#overview\&quot;">\r\n HDFC Bank &lt;\/a&gt;\r\n &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n </a>
                              </div></td>
                              <td class="\&quot;td-link\&quot;">\r\n 
                              <div class="fixed-width-cell fixed-width-cell-mob">
                              \r\n <a class="\&quot;custom-fund-name\&quot;\r\n" href="\&quot;\/stocks\/selector\/sector\/8\/\&quot;">\r\n Financial &lt;\/a&gt;\r\n &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n </a>
                              </div></td>
                              <td class="\&quot;mono-font\&quot;">\r\n <div\r\n class="\&quot;table-text-right" fixed-width-cell fixed-width-cell-mob text-right\>
                              \r\n 21.26 &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n 
                              </div\r\n></td>
                              <td class="\&quot;td-bg" mono-font text-right\>\r\n 
                              <div class="\&quot;table-text-right" fixed-width-cell fixed-width-cell-mob\>
                              \r\n <span\r\n class="\&quot;asset-circle-bg\&quot;">
                              &lt;\/span&gt;7.52 &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n 
                              </span\r\n>
                              </div></td>
                              <td class="\&quot;text-center\&quot;">
                              <a\r\n href="\&quot;\/premium\/subscribe\/?utm_medium=vro&amp;utm_campaign=premium-unlock&amp;utm_source=fund-details\&quot;">
                              \r\n 
                              <div class="\&quot;unlock-premium" w-70\>
                              <img\r\n src="\&quot;\/asts\/img\/icons\/premium-lock.svg\&quot;\r\n" alt="\&quot;unlock" premium\ width="\&quot;20\&quot;" data-toggle="\&quot;tooltip\&quot;\r\n" data-placement="\&quot;top\&quot;" tabindex="\&quot;0\&quot;" data-html="\&quot;true\&quot;\r\n" title="\&quot;<p">
                              Unlock with Premium&lt;\/p&gt;\"\r\n data-template=\"
                              <div class="tooltip unlock-premium-tooltip" role="tooltip">
                              <div class="arrow">
                              &lt;\/div&gt;
                              <div class="tooltip-inner">
                              &lt;\/div&gt;&lt;\/div&gt;\" \/&gt;\r\n &lt;\/div&gt;\r\n &lt;\/a&gt;&lt;\/td&gt;\r\n &lt;\/tr&gt;\r\n
                              </div>
                              </div>
                              </div>
                              </img\r\n>
                              </div>
                              </a\r\n></td>
                              </tr>
                              <tr>
                              \r\n 
                              <td class="\&quot;table-text\&quot;">\r\n 
                              <div class="\&quot;first-col-custom-width\&quot;">
                              \r\n <img src="\/asts\/img\/equalarrow.gif" width="12" height="8" alt="equal"> <a class="\&quot;custom-fund-name\&quot;\r\n" href="\&quot;\/stocks\/42508\/icici-bank-ltd#overview\&quot;">\r\n ICICI Bank &lt;\/a&gt;\r\n &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n </a>
                              </div></td>
                              <td class="\&quot;td-link\&quot;">\r\n 
                              <div class="fixed-width-cell fixed-width-cell-mob">
                              \r\n <a class="\&quot;custom-fund-name\&quot;\r\n" href="\&quot;\/stocks\/selector\/sector\/8\/\&quot;">\r\n Financial &lt;\/a&gt;\r\n &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n </a>
                              </div></td>
                              <td class="\&quot;mono-font\&quot;">\r\n <div\r\n class="\&quot;table-text-right" fixed-width-cell fixed-width-cell-mob text-right\>
                              \r\n 23.05 &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n 
                              </div\r\n></td>
                              <td class="\&quot;td-bg" mono-font text-right\>\r\n 
                              <div class="\&quot;table-text-right" fixed-width-cell fixed-width-cell-mob\>
                              \r\n <span\r\n class="\&quot;asset-circle-bg\&quot;">
                              &lt;\/span&gt;7.48 &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n 
                              </span\r\n>
                              </div></td>
                              <td class="\&quot;text-center\&quot;">
                              <a\r\n href="\&quot;\/premium\/subscribe\/?utm_medium=vro&amp;utm_campaign=premium-unlock&amp;utm_source=fund-details\&quot;">
                              \r\n 
                              <div class="\&quot;unlock-premium" w-70\>
                         

enter image description here

I need to choose value ICICI Bank from

<a class="\&quot;custom-fund-name\&quot;\r\n" href="\&quot;\/stocks\/42508\/icici-bank-ltd#overview\&quot;">\r\n ICICI Bank &lt;\/a&gt;\r\n &lt;\/div&gt;\r\n &lt;\/td&gt;\r\n </a>

What should be CSS in this case ?

0 Answers
Related