0
import requests
from bs4 import BeautifulSoup

URL="https://kissanime.to"
page = requests.get(URL)

Code = BeautifulSoup(page.content,"html.parser")
print Code.title

This is the output

<title>Please wait 5 seconds...</title>

Every time i request from this site this is the only thing i get. Is there a way to get around this and get the HTML code from the actual site?

I want to get:

<title>KissAnime - Watch anime online in high quality</title>
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
forest203
  • 3
  • 4

1 Answers1

1

This particular website is quite dynamic and it needs a real browser to be loaded in. Let's control PhantomJS headless browser through the selenium WebDriver, load the page and wait for the title not to be equal "Please wait 5 seconds...":

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.PhantomJS()
driver.get("https://kissanime.to")

# wait for title not be equal to "Please wait 5 seconds..."
wait = WebDriverWait(driver, 10)
wait.until(lambda driver: driver.title != "Please wait 5 seconds...")

print(driver.title)

Prints:

KissAnime - Watch anime online in high quality
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • i downloaded selenium and PhantomJS but i keep getting a path error that i can't figure out how to fix. WebDriverException: Message: 'phantomjs' executable needs to be in PATH. Where should i put phantomjs? – forest203 Feb 04 '16 at 21:49
  • @forest203 well, this certainly goes out of scope of this particular topic. If you cannot solve it on your own or find a solution on the web, see if it makes sense to create a separate question here on SO. Thanks for understanding. – alecxe Feb 04 '16 at 21:50
  • path=r'C:\Users\Forest\Desktop\New folder\phantomjs-2.1.1-windows\bin\phantomjs.exe' driver.PhantomJS(executable_path=path) did not know you needed an r before the path – forest203 Feb 04 '16 at 22:34
  • I was wondering if it was possible to have phantomJS black box not show up when i run this? – forest203 Feb 04 '16 at 22:44
  • @forest203 interesting question, there is a C# specific solution here: http://stackoverflow.com/questions/20711407/selenium-webdriver-phantomjs-c-sharp-always-opens-a-cmd-window. See if it makes sense to create a python+selenium+phantomjs specific question about it. Thanks. – alecxe Feb 04 '16 at 22:51