I am in need to scrape the data from the website here . This was protected by Incapsula. I have already done two approaches and also used the techniques which were given by Stack Overflow users.
APPROACH 1 :
from incapsula import IncapSession
headers = {'Host': 'www.vignanam.org',
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/7.0.540.0 Safari/534.10',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate',
'Connection': 'keep-alive',
'Cookie': 'visid_incap_1642409=B+YoelHCSKKN5z/Phs0zXCsF9VsAAAAAQUIPAAAAAACXaWvcNDXdMzcOky/SvffB; incap_ses'
'_715_1642409=kyFvSyJuuBVpNuh+aTHsCSsF9VsAAAAAKV6TIWTPSZmb+mOZWeuNHA==',
'Upgrade-Insecure-Requests': '1'}
session = IncapSession()
response = session.get('http://www.vignanam.org/index.htm#&panel1-1', headers=headers, bypass_crack=True)
print response.text
APPROACH 2:
from mechanize import Browser
from bs4 import BeautifulSoup
browser = Browser()
browser.open('https://www.incapsula.com/blog/how-incapsula-protects-against-data-leaks.html')
print browser.response()
soup = BeautifulSoup(browser.response().read(), features='html5lib')
print soup
Both approaches are producing the same results.
RESULT/OUTPUT
<html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow">
<script src="/_Incapsula_Resource SWJIYLWA=5074a744e2e3d891814e9a2dace20bd4,719d34d31c8e3a6e6fffd425f7e032f3"> </script>
<body>
</body>
</html>
How to break this and scrape the data from there? Is any other programming languages to overcome this?
This :
import requests
requests.get('http://www.vignanam.org/index.htm#&panel1-1').text
worked fine for me.
I didn't see any kind of incapsula protection and it didn't block my request.
( curl http://www.vignanam.org/index.htm#&panel1-1
worked too in bash)
Returns :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" itemscope itemtype="http://schema.org/Organization">\n<head>\n<title>Vaidika Vignanam - Vedic Chants, Siva, Vishnu, Devi\nStotrams, Annamayya, Tyagaraja, Ramadasa Keerthanas in Sanskrit, Hindi,\nTelugu, Tamil, Kannada, Malayalam, Gujarati, Bengali and Oriya</title>\n<link rel=stylesheet type="text/css" href="css/vignanam.css"/>\n<link rel=stylesheet href="css/anythingslider.css" type="text/css" media=screen />\n<link type="text/css" href="css/jquery-ui-1.8.12.custom.css" rel=Stylesheet />\n<link rel=stylesheet href=aqtree3clickable.css />\n<link rel=stylesheet href="css/glowtabs.css" type="text/css" media=screen />\n<meta content="text/html; charset=utf-8" http-equiv=Content-Type />\n<meta name=keywords content="vedas, vedic chants, shiva stotrams, vishnu stotrams, \n\t\tdevi ......
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.