Python TypeError Traceback (most recent call last)
<p>I am trying the build a crawler, and I want to print all the links on that page
I am using Python 3.5</p>

<p>there is my code </p>

<pre><code>import requests
from bs4 import BeautifulSoup
def crawler(link):
    source_code = requests.get(link)
    source_code_string = str(source_code)
    source_code_soup = BeautifulSoup(source_code_string,'lxml')
    for item in source_code_soup.findAll("a"):
        title = item.string
        print(title)

crawler("https://www.youtube.com/watch?v=pLHejmLB16o")
</code></pre>

<p>but I get the error like this</p>

<pre><code>TypeError                                 Traceback (most recent call last)
&lt;ipython-input-13-9aa10c5a03ef&gt; in &lt;module&gt;()
----&gt; 1 crawler('http://archive.is/DPG9M')

TypeError: 'module' object is not callable
</code></pre>

<p>If you are intentions are to just print the titles of the link, you are making a small mistake, replace the line :</p>

<pre><code>source_code_string = str(source_code)
</code></pre>

<p>use </p>

<pre><code>source_code_string = source_code.text 
</code></pre>

<p>Apart from that the code looks fine and is running.
lets call the file web_crawler_v1.py</p>

<pre><code>import requests
from bs4 import BeautifulSoup
def crawler(link):
    source_code = requests.get(link)
    source_code_string = source_code.text 
    source_code_soup = BeautifulSoup(source_code_string,'lxml')
    for item in source_code_soup.findAll("a"):
        title = item.string
        print(title)


crawler("https://www.youtube.com/watch?v=pLHejmLB16o")
</code></pre>

<p>And about that error, you should not be getting that error if you are calling the file properly like this</p>

<pre><code>python3 wen_crawler_v1.py
</code></pre>

python web-crawler