Why can't i scrape the particular Amazon music page with selenium python?












0















https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP



The pure above mentioned link, not the link that one is directed to once clicking on it with the stack overflow tag.



This is the url.



def get_soup(url):
headers = {'User-Agent':
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
}
r = requests.get(url, headers=headers)
r.raise_for_status()
return BeautifulSoup(r.text, 'lxml')

url = input("Please enter an Amazon music url:")
soup = get_soup(url)


I get an error when requesting through it, why is that so?



Please enter an Amazon music url:https://www.amazon.com/Prettymuch-EP- 
PRETTYMUCH/dp/B07CF6YXDP
Traceback (most recent call last):
File "D:/Pycharm (4)/selemin.py", line 4, in <module>
import amazon
File "D:Pycharm (4)amazon.py", line 63, in <module>
soup = get_soup(url)
File "D:Pycharm (4)amazon.py", line 12, in get_soup
r.raise_for_status()
File "C:UsersHPAppDataLocalProgramsPythonPython37-32libsite-
packagesrequestsmodels.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url:
https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP%20









share|improve this question





























    0















    https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP



    The pure above mentioned link, not the link that one is directed to once clicking on it with the stack overflow tag.



    This is the url.



    def get_soup(url):
    headers = {'User-Agent':
    'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
    }
    r = requests.get(url, headers=headers)
    r.raise_for_status()
    return BeautifulSoup(r.text, 'lxml')

    url = input("Please enter an Amazon music url:")
    soup = get_soup(url)


    I get an error when requesting through it, why is that so?



    Please enter an Amazon music url:https://www.amazon.com/Prettymuch-EP- 
    PRETTYMUCH/dp/B07CF6YXDP
    Traceback (most recent call last):
    File "D:/Pycharm (4)/selemin.py", line 4, in <module>
    import amazon
    File "D:Pycharm (4)amazon.py", line 63, in <module>
    soup = get_soup(url)
    File "D:Pycharm (4)amazon.py", line 12, in get_soup
    r.raise_for_status()
    File "C:UsersHPAppDataLocalProgramsPythonPython37-32libsite-
    packagesrequestsmodels.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 404 Client Error: Not Found for url:
    https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP%20









    share|improve this question



























      0












      0








      0








      https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP



      The pure above mentioned link, not the link that one is directed to once clicking on it with the stack overflow tag.



      This is the url.



      def get_soup(url):
      headers = {'User-Agent':
      'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
      }
      r = requests.get(url, headers=headers)
      r.raise_for_status()
      return BeautifulSoup(r.text, 'lxml')

      url = input("Please enter an Amazon music url:")
      soup = get_soup(url)


      I get an error when requesting through it, why is that so?



      Please enter an Amazon music url:https://www.amazon.com/Prettymuch-EP- 
      PRETTYMUCH/dp/B07CF6YXDP
      Traceback (most recent call last):
      File "D:/Pycharm (4)/selemin.py", line 4, in <module>
      import amazon
      File "D:Pycharm (4)amazon.py", line 63, in <module>
      soup = get_soup(url)
      File "D:Pycharm (4)amazon.py", line 12, in get_soup
      r.raise_for_status()
      File "C:UsersHPAppDataLocalProgramsPythonPython37-32libsite-
      packagesrequestsmodels.py", line 940, in raise_for_status
      raise HTTPError(http_error_msg, response=self)
      requests.exceptions.HTTPError: 404 Client Error: Not Found for url:
      https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP%20









      share|improve this question
















      https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP



      The pure above mentioned link, not the link that one is directed to once clicking on it with the stack overflow tag.



      This is the url.



      def get_soup(url):
      headers = {'User-Agent':
      'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
      }
      r = requests.get(url, headers=headers)
      r.raise_for_status()
      return BeautifulSoup(r.text, 'lxml')

      url = input("Please enter an Amazon music url:")
      soup = get_soup(url)


      I get an error when requesting through it, why is that so?



      Please enter an Amazon music url:https://www.amazon.com/Prettymuch-EP- 
      PRETTYMUCH/dp/B07CF6YXDP
      Traceback (most recent call last):
      File "D:/Pycharm (4)/selemin.py", line 4, in <module>
      import amazon
      File "D:Pycharm (4)amazon.py", line 63, in <module>
      soup = get_soup(url)
      File "D:Pycharm (4)amazon.py", line 12, in get_soup
      r.raise_for_status()
      File "C:UsersHPAppDataLocalProgramsPythonPython37-32libsite-
      packagesrequestsmodels.py", line 940, in raise_for_status
      raise HTTPError(http_error_msg, response=self)
      requests.exceptions.HTTPError: 404 Client Error: Not Found for url:
      https://www.amazon.com/Prettymuch-EP-PRETTYMUCH/dp/B07CF6YXDP%20






      python beautifulsoup amazon






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 3:16









      Aqueous Carlos

      299313




      299313










      asked Nov 16 '18 at 3:06









      Durian JaykinDurian Jaykin

      126




      126
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Look at what the error is telling you - it's a different url. In particular, it's throwing an error because it ends with %20. This means there was a space at the end of your input. I would recommend processing your input to avoid this, something like



          new_url = url.strip()





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330843%2fwhy-cant-i-scrape-the-particular-amazon-music-page-with-selenium-python%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Look at what the error is telling you - it's a different url. In particular, it's throwing an error because it ends with %20. This means there was a space at the end of your input. I would recommend processing your input to avoid this, something like



            new_url = url.strip()





            share|improve this answer




























              1














              Look at what the error is telling you - it's a different url. In particular, it's throwing an error because it ends with %20. This means there was a space at the end of your input. I would recommend processing your input to avoid this, something like



              new_url = url.strip()





              share|improve this answer


























                1












                1








                1







                Look at what the error is telling you - it's a different url. In particular, it's throwing an error because it ends with %20. This means there was a space at the end of your input. I would recommend processing your input to avoid this, something like



                new_url = url.strip()





                share|improve this answer













                Look at what the error is telling you - it's a different url. In particular, it's throwing an error because it ends with %20. This means there was a space at the end of your input. I would recommend processing your input to avoid this, something like



                new_url = url.strip()






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 16 '18 at 3:45









                tigerninjamantigerninjaman

                10511




                10511






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330843%2fwhy-cant-i-scrape-the-particular-amazon-music-page-with-selenium-python%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Tangent Lines Diagram Along Smooth Curve

                    Yusuf al-Mu'taman ibn Hud

                    Zucchini