How to get a specific HTML tags
<p>I'm trying to get a HTML tags if the item has no text.<br>
For instance: I am looping through all the "a" attributes(URL).<br>
However, some of the URL has text in it and some don't.<br>
In this case I'm trying to get the URL for the ones that don't have text on it.<br>
Therefore, I did something like this.</p>

<pre><code>response = requests.get('https://fw.tmall.com/tmall/ser/tmall_detail.htm?spm=a1z1g.2177293.0.0.qF9gPO&amp;service_code=ts-4078').text
soup = BeautifulSoup(response)
main_wrapper = soup.find('div',attrs={'id':'success-case'}).findAll('a')
for items in main_wrapper:
    dictionary = {}
    href = items['href']
    if items.string is None:
        print items['href']
    else:
        print items.string
</code></pre>

<p>How do I do it so that <code>if items.string is None:</code> get that item specific URL only and not all the URL?</p>

<p>I presume you are trying to get the unique anchors from the <em>unordered list</em> inside your <em>div</em>. You can see each anchor has a unique class, <code>rel-ink</code> vs <code>rel-name</code>:</p>

<pre><code> &lt;a href="//store.taobao.com/shop/view_shop.htm?user_number_id=2469022358" target="_blank" class="rel-ink"&gt;&lt;img alt="NIHAOMARKETå®æ¹æµ·å¤æè°åº" src="//img.alicdn.com/top/i1/TB1urimJFXXXXabaXXXwu0bFXXX.png" class="rel-img"&gt;&lt;/a&gt;
 &lt;a href="//store.taobao.com/shop/view_shop.htm?user_number_id=2469022358" target="_blank" class="rel-name"&gt;NIHAOMARKETå®æ¹æµ·å¤æè°åº&lt;/a&gt;
</code></pre>

<p>So  you can use the anchor class name for the first anchor inside each <em>li</em>  i.e <em>rel-ink</em> to get them:</p>

<pre><code>urls =[a["href"] for a in soup.find('div', id="success-case").find_all("a",class_="rel-ink")]
</code></pre>

<p>Or using a <em>css selector</em>:</p>

<pre><code>urls = [a["href"] for a in soup.select("#success-case ul li a.rel-ink")]
</code></pre>

<p>Both will give you:</p>

<pre><code>['//store.taobao.com/shop/view_shop.htm?user_number_id=692020965', '//store.taobao.com/shop/view_shop.htm?user_number_id=2087799889', '//store.taobao.com/shop/view_shop.htm?user_number_id=2469022358', '//store.taobao.com/shop/view_shop.htm?user_number_id=377676745', '//store.taobao.com/shop/view_shop.htm?user_number_id=2367059695', '//store.taobao.com/shop/view_shop.htm?user_number_id=449764134', '//store.taobao.com/shop/view_shop.htm?user_number_id=698389964', '//store.taobao.com/shop/view_shop.htm?user_number_id=509711360', '//store.taobao.com/shop/view_shop.htm?user_number_id=692020965', '//store.taobao.com/shop/view_shop.htm?user_number_id=1125022434', '//store.taobao.com/shop/view_shop.htm?user_number_id=1071997040', '//store.taobao.com/shop/view_shop.htm?user_number_id=795947607', '//store.taobao.com/shop/view_shop.htm?user_number_id=509711360', '//store.taobao.com/shop/view_shop.htm?user_number_id=692020965', '//store.taobao.com/shop/view_shop.htm?user_number_id=1071997040', '//store.taobao.com/shop/view_shop.htm?user_number_id=509711360', '//store.taobao.com/shop/view_shop.htm?user_number_id=377676745', '//store.taobao.com/shop/view_shop.htm?user_number_id=2367059695', '//store.taobao.com/shop/view_shop.htm?user_number_id=2469022358']
</code></pre>

python parsing beautifulsoup