I want to scrape through web pages that are selected from drop down as shown below
<h1>Scraping Test</h1>
<form action="/tests/scraping" method='post'>
<input type="hidden" name="csrf_token" value="1499585369##d2d1570f820aec0589b3bd5f4ab4e7df913e25ff"/>
<table>
<tr>
<td>Select Ward: </td>
<td>
<select name="ward">
<option value=''>-- select --</option>
<option value='DHANLAXMICOMPLEX'>DHANLAXMICOMPLEX</option>
<option value='POTALIYA'>POTALIYA</option>
<option value='ARJUNTOWER'>ARJUNTOWER</option>
<option value='NEWCLOTHMARKET'>NEWCLOTHMARKET</option>
<option value='CHANAKYAPURI'>CHANAKYAPURI</option>
<option value='BHAIKAKANAGAR'>BHAIKAKANAGAR</option>
<option value='RADHASWAMYROAD'>RADHASWAMYROAD</option>
<option value='SATADHAR'>SATADHAR</option>
<option value='AMRUTAVIDYALAYA'>AMRUTAVIDYALAYA</option>
<option value='AGARWALTOWERS'>AGARWALTOWERS</option>
<option value='RANNAPARK'>RANNAPARK</option>
<option value='IIM'>IIM</option>
<option value='VEJALPURWARD'>VEJALPURWARD</option>
<option value='GITAMANDIR'>GITAMANDIR</option>
</select>
</td>
<td><input type="submit" value="Search" class="search"/></td>
</tr>
</table>
how to request a webpage from that drop down menu and there is also a search button
my code
import requests, csv
from lxml import html
def get_all_pages():
payload = {'value':'DHANLAXMICOMPLEX'}
url = requests.get('https://recruitment.advarisk.com/tests/scraping',data=payload)
print(url.text)
There is a token value which you can get from this HTML element
<input type="hidden" name="csrf_token" value="1499585369##d2d1570f820aec0589b3bd5f4ab4e7df913e25ff"/>
and use in your request. Try to use below code and let me know in case of any issues
import lxml.html
import requests
url = "https://recruitment.advarisk.com/tests/scraping"
s = requests.session()
r = s.get(url)
source = lxml.html.document_fromstring(r.content)
token = source.xpath('//input[#name="csrf_token"]/#value')[0]
headers = {'Referer': 'https://recruitment.advarisk.com/tests/scraping'}
data = {'csrf_token': token, 'ward': 'DHANLAXMICOMPLEX'}
print(s.post(url, data=data, headers=headers).text)
Related
is there a chance to search with evoSearch with 3 items? I would like the search results page to show the result only if the page meets all 3 conditions? TVs added to the document will be checkboxes with the possibility of multiple selection
Below is a screen that should help
https://imgur.com/a/1uKN2N0#t9hgC5x
Search page code
<form action="[~24~]" id="praca" method="get">
<div>
<label for="language">Language:</label>
<select type="text" name="language" id="language" class="form">
<option selected="" value="english">english</option>
<option value="spanish">spanish</option>
<option value="german">german</option>
<option value="polish">polish</option>
</select>
</div>
<div>
<label for="localisation">Localisation:</label>
<select type="text" name="localisation" id="localisation" class="form">
<option selected="" value="italy">Italy</option>
<option value="Greece">Greece</option>
<option value="Spain">Spain</option>
<option value="Portugese">Portugese</option>
</select>
</div>
<div>
<label for="category">Category:</label>
<select type="text" name="category" id="category" class="form">
<option selected="" value="it-service">IT service</option>
<option value="helpdesk">Helpdesk</option>
<option value="callcenter">Call center</option>
<option value="support">Support</option>
</select>
</div>
<button type="submit">Search</button>
</form>
Search results page
[!evoSearch?
&display=`10`
&filters=`AND(
content:c.template:notin:27,28;
content:c.id:notin:23,88;
)`
&tvPrefix=``
&tvList=`language,localisation,category`
&renderTV=`language,localisation,category`
&ownerTPL=`#CODE:[+dl.wrap+]`
&tpl=`evoSearch`
&statTpl=`<p>Showing results [+stat_from+] - [+stat_to+] of [+stat_total+] for "[+stat_request+]"</p>`
&noResult=`<p>Nothing was found for "[+stat_request+]"</p>`
!]
It can also be AjaxSearch, I have code like below, but unfortunately it searches for one criteria.
Adding advSearch = 'allwords' causes it to find nothing
[!AjaxSearch?
&clearDefault=`1`
&showResults=`0`
&landingPage=`12`
&showMoreResults=`1`
&moreResultsPage=`12`
&output=`0`
&whereSearch=`tv`
&withTvs=`category,language,localisation`
&tvPhx=`category,language,localisation`
&tplInput=`#FILE:assets/snippets/ajaxSearch/templates/inputTemplates/input3.tpl.html`
!]
input3.tpl.html code
[+as.showInputForm:is=`1`:then=`
<form id="[+as.formId+]" action="[+as.formAction+]" method="post">
<fieldset>
<div>
<label for="language">Language:</label>
<select name="search[]" id="ajaxSearch_select" class="form">
<option value="english">english</option>
<option value="spanish">spanish</option>
<option value="german">german</option>
<option value="polish">polish</option>
</select>
</div>
<div>
<label for="localisation">Localisation:</label>
<select name="search[]" id="ajaxSearch_select2" class="form">
<option selected="" value="italy">Italy</option>
<option value="Greece">Greece</option>
<option value="Spain">Spain</option>
<option value="Portugese">Portugese</option>
</select>
</div>
<div>
<label for="category">Category:</label>
<select name="search[]" id="ajaxSearch_select3" class="form">
<option selected="" value="it-service">IT service</option>
<option value="helpdesk">Helpdesk</option>
<option value="callcenter">Call center</option>
<option value="support">Support</option>
</select>
</div>
[+as.showAsId:is=`1`:then=`<input type="hidden" name="[+as.asName+]" value="[+as.asId+]" />`+]
<input type="hidden" name="advsearch" value="[+as.advSearch+]" />
<label>
<input id="[+as.submitId+]" type="submit" name="sub" value="[+as.submitText+]" />
</label>
</fieldset>
</form>
[+as.showIntro:is=`1`:then=`
<p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
`+]
`+]
I am trying to insert the attribute "selected" into the first option (volvo) with Jekyll without writing anything in the form.
I guess I should do it with capture but don't get how it works for passing attributes.
cars.html
<html>
<body>
...
<form action="/action_page.php">
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<br><br>
<input type="submit" value="Submit">
</form>
...
</body>
</html>
Here I'm having no_of_devices which has three fields 'macAddress', 'useWith' and 'type' in a row, the count of row depends upon the number of devices selected from select field, so I'm using body-parser and i want to get all the row data which has name generated using for loop so all the rows having macAddress will have name='macAdd0',name="macAdd1" etc same goes with 'type' and 'useWith' field.
HTML
<select id="noOfDevice" class="form-control" name="noOfDevice" onchange="getDeviceCount(this)">
<option selected value="0">Select</option>
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
</select>
Javascript
<script>
var macAdd;
var useWith;
var type;
var noOfDevice = req.body.noOfDevice;
for (var i = 0; i < noOfDevice; i++) {
var k = i.toString();
macAdd[i] = req.body.macAdd[i];
useWith[i] = req.body.useWith[i];
type[i] = req.body.type[i];
//console.log(req.body.macAdd);
process.deviceManger(macAdd[i], useWith[i], type[i]);
console.log('Device' + i + 'Details Update');
}
function getDeviceCount(sel) {
console.log("No of Device:" + sel.value);
var currCount = sel.value;
var div = document.createElement("div");
for (var i = 0; i < currCount; i++) {
div.setAttribute('id', 'addElements');
div.innerHTML += '<div class="row"><div class="form-row"><div class="form-group col-md-3"><label for="inputCity">Mac Address</label><input type="text" class="form-control" id="macAdd" name="macAdd' + i + '"></div> <div class="form-group col-md-3"><label for="inputState">Type of Device</label> <select id="inputState" class="form-control" name="deviceType' + i + '"> <option selected>Select</option> <option value="Irys Slate">Irys Slate</option> <option value="Irys Sling">Irys Sling</option> <option value="Irys Swing">Irys Swing</option> </select> </div> <div class="form-group col-md-3"> <label for="inputState">Use with</label> <select id="inputState" class="form-control" name="useWith' + i + '"> <option selected>Select</option> <option value="All">All</option> <option value="Nconnect">Nconnect</option> <option value="Tiara">Tiara</option> <option value="Corona">Corona</option> <option value="TiaraMini">TiaraMini</option> <option value="Nconnect+Tiara">Nconnect+Tiara</option> <option value="Nconnect+Corona">Nconnect+Corona</option> <option value="Nconnect+TiaraMini">Nconnect+TiaraMini</option> </select> </div> </div> </div>';
document.getElementById("devices").appendChild(div);
}
}
</script>
When i am changing my option value of select it's ng-model value is not being changed.
Is this happening because of value is being changed by Jquery?
Because i read a line about angularjs from w3school that The ng-change event is only triggered if there is a actual change in the input value, and not if the change was made from a JavaScript.
And i want to clarify that option value is being changed by j query.
Please suggest me proper solution or tell me error in the code.
Here is my html
<div class="row" ng-app="myapp" ng-controller="mycontroller" id="mainController">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="form-group">
<p>Rooms
<% no_of_rooms %>
</p>
<select ng-init="no_of_rooms='1'" autocomplete="off" ng-model="no_of_rooms" class="form-control" id="no_of_rooms" style='display:none' name="no_of_room" style="height: 39px !important;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12" ng-repeat="i in getNumber(no_of_rooms) track by $index">
<div class="form-group">
<p>Adult (12+ YRS)</p>
<select autocomplete="off" class="form-control" style='display:none' name="no_of_adults[]" style="height: 39px !important;">
<option value="0">0</option>
<option value="1" Selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</div>
</div>
</div>
Here is my script.
var app = angular.module('myapp', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
app.controller('mycontroller', function($scope , $filter) {
$scope.getNumber = function(num) {
return new Array(parseInt(num));
}
});
$(document).ready(function(){
$(".btn").hide();
$(".about input").on('click',function(){
$(".about input").hide();
$(".btn").show();
});
});
" method="post" enctype="multipart/form-data">
save as
cover
logo
save
<select name="save">
<option selected="selected">save as<option>
<option value="coverimage">cover<option>
<option value="logo">logo<option>
</select>
<input type="file" name="image"></input>
<button class="btn">save</button>
</form>
initially hiding ".btn", but after clicking ".about input" want to hide ".about input" and show ".btn"