-1

Although I have tried many times and have tried using user-agent. I even used beautifulSoup. The site does not allow me to enter.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

opts = Options()
opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36")

driver_path = "F:/chromedriver"
browser = webdriver.Chrome(executable_path=driver_path,chrome_options=opts)

browser.get("https://www.sahibinden.com/ilan/emlak-konut-satilik-incesu-garipcede-evli-bag-835829825/detay")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
feyZ1g
  • 62
  • 8

2 Answers2

0

Remove .exe in your driver_path should work. Something like this:

driver_path = "path/to/your/chromedriver/without/exe"

After you downloaded chromedriver based on your chrome version, you need to give a full path to the chromedriver without .exe extension.

liamsuma
  • 156
  • 4
  • 19
  • I've tried. I am having trouble entering the site. https://imgur.com/36WvF0W " we detected unusual access" – feyZ1g Jun 26 '20 at 16:56
  • which website do you want to have access to? the one in OP or the one you just commented? @FeyzullahErtan – liamsuma Jun 26 '20 at 17:00
  • This site: https://www.sahibinden.com/ilan/emlak-konut-satilik-incesu-garipcede-evli-bag-835829825/detay – feyZ1g Jun 26 '20 at 17:06
  • Remove `www` in your script to see if that solves your issue. @FeyzullahErtan – liamsuma Jun 26 '20 at 17:17
  • [https://stackoverflow.com/questions/60006165/how-can-i-auto-login-sahibinden-com] this link mentioned the website that you want to access to. Might be helpful to take a look at. @FeyzullahErtan – liamsuma Jun 26 '20 at 17:27
  • Unfortunately, I did what was written on this subject. In the screenshot above, it gives "unable to access" error. – feyZ1g Jun 27 '20 at 09:05
0

I have used your code along with some simple tweaks as follows:

  • Code Block:

    from selenium import webdriver
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get('https://www.sahibinden.com/ilan/emlak-konut-satilik-incesu-garipcede-evli-bag-835829825/detay')
    print(driver.page_source)
    
  • Browser Snapshot:

sahibinden

  • Console Output:

<html>

<head>
  <title></title>
  <style>
      .preloader {
      width: 100%;
      height: 100%;
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background-image: url('data:image/gif;base64,R0lGODlhQABAAOMAAAQCBMTCxERGRCQiJOzq7BQSFNTW1GRmZCwuLAwKDMTGxOzu7BQWFHRydDQyNP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQIBgAAACwAAAAAQABAAAAEbPDJSau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqPyKRyyWw6n9CodEqtWq/YrHbL7Xq/4LB4TN4tDoyEwJAkDABwuALZiMcRSIQ9Tjjq9wB9RnV7eEdue3NIBAcFamwsEQAh
     . 
     .
     . 
     (function(e) {
        e.initCustomEvent("teXnghGbT", false, false, ["A6t9_fFyAQAAM-1AOljwDCGitC0v7vJY1or4qXqaS99_QKcxspE6OkxCHBLxAZ0vMOCucnW8wH8AAEB3AAAAAA==", "vZ1z8n9UIltBkSR7DqW0Fg5LuAcJHoa2fC6iw_bmyPTYMNsQ-Oh3dVGK=EpxXj4er", [], [155272514, 740924909, 1776946185, 932189146, 1328352516, 633076428, 1104746011, 975810292], "jiGC/uEjFnRkm61qNb6PSPK4", "jiGC/uEjFnRkm61qNb6PSPK4", [], typeof arguments==="undefined"?void 0:arguments]);
        dispatchEvent(e)
      }
      (document.createEvent("CustomEvent")))</script><script>(function() {
        'use strict';
        var afterReadyCbCalled=false;
        var originalHeaders=["X-Origin-DC", "gytp", "X-Forwarded-For", "157.47.48.224", "X-Client-SrcPort", "51230", "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Accept-Language", "en-US,en;q=0.9", "X-Forwarded-Proto", "https", "X-TLS-Version", "771", "Upgrade-Insecure-Requests", "1", ];
        var originalBody="";
        function afterReadyCb() {
          if (afterReadyCbCalled) return;
          afterReadyCbCalled=true;
          var xhr=new XMLHttpRequest();
          xhr.onload=function() {
            var isValid=xhr.getResponseHeader("ISTL-INFINITE-LOOP");
            if (isValid !=null && isValid !='') return;
            var a=xhr.getResponseHeader("ISTL-REDIRECT-TO");
            if (a !=null && a !='') {
              location.replace(a);
            }
            else {
              if (window.history !=null && typeof history.replaceState==='function') {
                var responseURL=xhr.responseURL !=null ? xhr.responseURL: xhr.getResponseHeader("ISTL-RESPONSE-URL");
                if (responseURL !=null && responseURL !='') {
                  history.replaceState(null, '', responseURL);
                }
              }
              document.open();
              document.write(xhr.responseText);
              document.close();
            }
          }
          ;
          xhr.open("get", location.href, true);
          for (var i=0;
          i < originalHeaders.length;
          i +=2) {
            var headerName=originalHeaders[i];
            try {
              xhr.setRequestHeader(headerName, originalHeaders[i + 1]);
            }
            catch (e) {}
          }
          xhr.setRequestHeader("ISTL-INFINITE-LOOP", '1');
          xhr.send(originalBody);
          var evt=document.createEvent('Event');
          evt.initEvent('QLpZFJdHv', true, true);
          dispatchEvent(evt);
        }
        addEventListener('afterReady', afterReadyCb, false);
        setTimeout(afterReadyCb, 400);
      }
      ());
      </script><style>html,
      body {
        margin: 0;
        padding: 0;
        background-color: white;
      }
  </style>


  </body>

</html>

Conclusion

The message in the browser snapshot is in Turkish and it means:

We detected unusual access ... We see unusual (automatic) access to our site from your device or the network you are connected to. We cannot fulfill your request right now, you can try again soon.

It seems the Selenium driven WebDriver controlled Chrome Browsing Context gets detected and the navigation gets blocked.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352