Extracting links and titles only
<p>I am trying to extract links and titles for these links in an anime website, However, I am only able to extract the whole tag, I just want the href and the title.</p>

<p>Here`s the code am using:</p>

<pre><code>import requests
from bs4 import BeautifulSoup

r = requests.get('http://animeonline.vip/info/phi-brain-kami-puzzle-3')
soup = BeautifulSoup(r.content, "html.parser")
for link in soup.find_all('div', class_='list_episode'):
    href = link.get('href')
    print(href)
</code></pre>

<p>And here`s the website html:</p>

<pre><code>&lt;a href="http://animeonline.vip/phi-brain-kami-puzzle-3-episode-25" title="Phi Brain: Kami no Puzzle 3 episode 25"&gt;
                    Phi Brain: Kami no Puzzle 3 episode 25                  &lt;span&gt; 26-03-2014&lt;/span&gt;
        &lt;/a&gt;
</code></pre>

<p>And this is the output:</p>

<pre><code>C:\Python34\python.exe C:/Users/M.Murad/PycharmProjects/untitled/Webcrawler.py
None

Process finished with exit code 0
</code></pre>

<p>All that I want is all links and titles in that class (episodes and their links)</p>

<p>Thanks.</p>

<p>The entire page has only one element with class 'list_episode', so you can filter out the 'a' tags and then fetch the value for attribute 'href':</p>

<pre><code>In [127]: import requests
     ...: from bs4 import BeautifulSoup
     ...: 
     ...: r = requests.get('http://animeonline.vip/info/phi-brain-kami-puzzle-3')
     ...: soup = BeautifulSoup(r.content, "html.parser")
     ...: 

In [128]: [x.get('href') for x in soup.find('div', class_='list_episode').find_all('a')]
Out[128]: 
[u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-25',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-24',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-23',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-22',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-21',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-20',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-19',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-18',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-17',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-16',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-15',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-14',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-13',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-12',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-11',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-10',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-9',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-8',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-7',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-6',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-5',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-4',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-3',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-2',
 u'http://animeonline.vip/phi-brain-kami-puzzle-3-episode-1']
</code></pre>

python visual-studio web-scraping python-3.4 ptvs