I want to scrape star rate from this site:
http://www.pixel.ir/canon/3071-canon-eos-700d-18-55-is-stm.html
I can scrape text, but star rate are shown as a image.
in its source star rate are give by radio:
<div class="gsrReviewLineRating" id="gsrDisplayRating1"> <input class="star" type="radio"id="gsrRating1" name="gsrRating1" value="1" /><input class="star" type="radio" id="gsrRating1" name="gsrRating1" value="2" /><input class="star" type="radio" id="gsrRating1" name="gsrRating1" value="3" /><input class="star" type="radio" id="gsrRating1" name="gsrRating1" value="4" /><input class="star" type="radio" id="gsrRating1" name="gsrRating1" value="5" **checked**="checked"/></div>
I tried to scrape it with mozenda, but i cant,
is there any way to scrape it?
Is there other software for this purpose?
You can do this using Mozenda pretty easily. If you copy and paste the XML below into an agent it will create the action that will capture the star rating. To figure out how to capture it from multiple pages you can go here -- http://mozenda.com/help/helptopic?TopicID=149
<!--- - - - - - - - Actions - - - - - - - - -->
<ActionList>
<Action>
<ActionType>GetElementValue</ActionType>
<Page>1</Page>
<FieldExpression>value="%Star Rating%"</FieldExpression>
<FieldExpression>value='%Star Rating%'</FieldExpression>
<FieldExpression>value=%Star Rating% </FieldExpression>
<FieldExpression>value=%Star Rating%></FieldExpression>
<ItemType>PlaceHolder</ItemType>
<ItemXPath>//input[#name="gsrAverageRating"][5]</ItemXPath>
<ID>gsrAverageRating</ID>
<Name>gsrAverageRating</Name>
<FieldValueType>Outer</FieldValueType>
</Action>
</ActionList>
You have to grap value from checked input.
<input ... value="5" **checked**="checked"/>
I use python and requests, lxml modules:
import requests
import lxml, lxml.html
r = requests.get('http://www.pixel.ir/canon/3071-canon-eos-700d-18-55-is-stm.html')
html = lxml.html.fromstring(r.text)
checked = html.cssselect('input#gsrAverageRating[checked]')
if checked:
print checked[0].attrib.get('value', None)
else:
print "No stars"
Related
I'm quite a beginner, and I've been trying to make a form on Wordpress that would enable me to make calculations with the customer inputs, and then display the results in a table (rather in a new page).
I'm well aware that there a plenty of plugins on wp, and I've been using HTML forms plugin.
The thing is, I have my HTML form ready, and the plugin allows me to send the inputs by e-mail (which is already cool), but I have no idea of how to use those inputs, define variables that are dependent on those inputs, and to display them in a table..
Here is part of my HTML form :
<div class="slidecontainer">
<p>Fluid temperature (in ° C) :</p>
<input type="range" min="0" max="2000" value="200" class="slider" id="myRange">
<p>Temperature : <span id="demo" </span></p>
</div>
<div id="flow">
<label for="number">Fluid flow</label>
<input type="number" name="flow">
<select><p>select a unit:</p>
<option value="Nm^3">Nm^3</option>
<option value="kg/s">Kg/s</option>
</select>
</div>
<div id="running time">
<label for="number">Running time</label>
<input type="number" name="running time" min="0" max="8784">
<span>hours/year</span>
</div>
<div id="fluid purity">
<label for="text">Fluid purity</label>
<input type="radio" name="purity" value="0">0</input>
<input type="radio" name="purity" value="1">1</input>
<input type="radio" name="purity" value="2">2</input>
<input type="radio" name="purity" value="3">3</input>
<input type="radio" name="purity" value="4">4</input>
<input type="radio" name="purity" value="5">5</input>
</div>
Basically, I would like to display variables that depend on those inputs.
For example :
Let T be the input fluid temperature
Let F be the input flow of the fluid
Let Rt be the input running time in hours
Let P be the input fluid purity (with 0 ≤ P ≤ 5)
I would like to set the following variables:
Y (Yield) = 17% if T≤300°C
Y = 0.1*T - 13 if 300° ≤ T ≤ 350°
Y =22% if T>350°
Then an intermediate variable T(out)=20*P + 120
and Δ(T) = T – T(out)
that helps calculate the Thermal Power TPw
TPw = 0,00042 * Δ(T) * F if the input unit chosen is Nm^3/h
TPw= 0,00042 * (1/1,3)* F * Δ(T) * 3,6 * 10-6 if kg/s unit chosen
... That is just part of what I have to do but I have no idea of how to display those variables Y and TPw in a table after submiting my form :(
Would anyone have a clue ?
I have an angular 7 reactive form, input field in this form is to let user see and modify time and then using Save() save it back to our db, the problem is that user can enter any none sense numbers in this field which dose not make sense in terms of Time.(like hours should be 1-24, Minutes 1-60)
My question is how can I validate what user entered into time field and if its valid then let Save btn be active?
Note: Based on my testing even though its none sense time entry but while trying to save its not saving to db and its probably sql not letting that happen.
I googled but i could not find anything, also angular has only email Validators which u can put while defining form.
this is my form defination
timeForm: FormGroup = new FormGroup({
Id: new FormControl(''),
Time: new FormControl(''),
});
and this is my HTML side
<form style="background-color: aliceblue;" [formGroup]="service.timeForm">
<mat-grid-list cols="1" rowHeight="120px">
<mat-grid-tile>
<div class="form-controles-container">
<input type="hidden" formControlName="Id" />
<mat-form-field>
<input formControlName="Time" matInput placeholder="Time" />
</mat-form-field>
<div class="button-row">
<button mat-raised-button color="primary" type="submit" (click)="Save()">Save</button>
<button mat-raised-button color="warn" (click)="Cancel()">Cancel</button>
</div>
</div>
</mat-grid-tile>
</mat-grid-list>
</form>
I need some sort of validation when user punch in any input which dose not make sense in Time my Save btn should not be activated.
I appreciate your help and guideline.
You can use the HTML type="time" or if you want more you can simply use a library like: JsDaddy/ngx-mask found on Github. Use it like this:
HTML with MatInput:
<input formControlName="Time" matInput placeholder="Time" type="time" />
With ngx-mas:
<input formControlName="Time" matInput placeholder="Time" mask="Hh:m0" />
Adding type="time" in all input time type use cases always help.
I need add some custom attribues to inputs from Contact Form 7, but without using JS.
For eg. I need add data-timepicker="true" and data-language='en' - those attributes are for Air-Datepicker plugin.
I was trying create those attributes with JS and it's works, but not for Air-Datepicker - probably JS works to late.
So, how can I do that without JS?
You could just add the input directly into your form, after copying the output from the form on the page.
For example... If you add the form tag
<label>The Date</label>
[text* the-date]
on the output of the form when you view the source on the page you've pasted the contact form shortcode, you'll see this:
<label>Enter Date</label>
<span class="wpcf7-form-control-wrap the-date"><input type="text" name="the-date" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false"></span>
Then copy it back to your form and replace your form tag [the-date] with:
<label>Enter Date</label>
<span class="wpcf7-form-control-wrap the-date"><input type="text" name="the-date" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false" data-timepicker="true" data-language="en"></span>
Just make sure you include in your email [the-date] - as it won't show up on the mail tab to remind you.
Is there any way to have a slider and next to it an editable field with it's current value?
I am using MDL and not polymer, because its light weight and should be distributed with locally run software.
This is a way:
<input class="mdl-slider mdl-js-slider" type="range"
min="0" max="100" value="50" tabindex="0" id = "slide_01">
<form action="#">
<div class="mdl-textfield mdl-js-textfield" id="text_01">
<input class="mdl-textfield__input" type="text" >
</div>
</form>
and
$('#slide_01').on('input',function(){
$("#text_01").get(0).MaterialTextfield.change(this.value);
});
$('#inp_text_01').keyup(function() {
$("#slide_01").get(0).MaterialSlider.change($('#inp_text_01').val());
});
-- updated the code and the fiddle to make it update the slider when the value is entered in the field --
https://jsfiddle.net/n6xy84ov/
I think there should be a better way, referring to my question here:Fetching the value of a mdl-textfield
I have code similar to the below
<form action="/u" method="post">
<div class="reply">
<input type="hidden" name="type" value="2"/>
<input type="hidden" name="id" value="1"/>
<input type="hidden" name="parentId" value="0"/>
<textarea name="text" style="width: 500px; height: 200px;"></textarea><div class="rhs"><button>Post Comment</button></div></div>
</form>
It seems that i dont need a name for the editor to work however i need to use name so i can post the data. Issue is i do NOT get the text data that the user enters but the generated html from markdown editor. How do i set it so i get the normal raw html that the user types?
Change the output option from HTML to markdown.
It looks something like:
Attacklab.wmd_defaults = {
version: 1, output: "markdown", lineLength: 40, delayLoad: false
};
Although this question has already been answered here is an additional tip that may be of relevance: There is an easy way to post both the html and the markdown, by posting via javascript and using the preview component to get the html, and the textarea to get the markdown source. Here is a blog post by me with more details.