Flutter Web Scrapping: How to get a data between <> and <> - flutter

Used Third Package List: http.dart, dom.dart, parser.dart
Question: As you can see there are 16 between <span class= 'temperature_text> and , I want to get 16.
How can I get that 16?
HTML CODE
<div class='temperature_text'>
<strong>
<span class='blind'>Current Temp</span>
16
<span class='celsius'>°</span>
</strong>
</div>

Related

Map through an object in scala play framework map and include a file

I am using scala play framework.
On my scala.html page I am trying to loop through a list using a map function
In each loop I want to call an included page.
{profilesvm.profiles.map(profile=>{
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
#cards(profile)
</div>
}
Right now the #cards is coming out printed as straight text. instead of pulling the code.
Do I need to put something around the words #cards to make it run as scala?
Just had to adjust brackets.
<div class="col-md-10 col-sm-8 col-xs-12 ">
#featuredProfiles.map{profiles=>
<div id="featured-profiles" >
<div class="list col-xs-12">
#for(p <- profiles.profiles){
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 list-inside">
#cards(p){
}
</div>
}
}
</div>
</div>

How to use result of .length in selector Cypress

I'm trying to perform an action based on the results of an earlier assertion. I have the following situation, I want to determine the number of versions for a document, this is represented in the follwing html:
<ul data-testhook-id="accordion-body">
<li data-testhook-id="accordion-body-item">
<div>
<div data-testhook-id="version-1">
<div data-testhook-id="avatar">
<div data-id="tooltip">John Doe</div>
</div>
</div>
<span data-testhook-id="content">1. 17-08-2018 at 15:26</span>
</div>
<div data-testhook-id="version-2">
<div data-testhook-id="avatar">
<div data-id="tooltip">John Doe</div>
</div>
</div>
<span data-testhook-id="content">2. 20-08-2018 at 13:05</span>
</div>
<div data-testhook-id="version-3">
<div data-testhook-id="avatar">
<div data-id="tooltip">Jane Doe</div>
</div>
</div>
<span data-testhook-id="content">3. 20-08-2018 at 13:11</span>
</div>
<div data-testhook-id="version-4">
<div data-testhook-id="avatar">
<div data-id="tooltip">No Body</div>
</div>
</div>
<span data-testhook-id="content">4. 21-08-2018 at 13:11</span>
</div>
<svg width="12" height="12" data-testhook-id="icon-active-version"><path d="path-here"></path></svg>
</div>
</div>
</li>
Each element with test id data-testhook-id="version-xxx" is a line containing version information and its these div elements I want to count. for this I have set up the following:
cy.get('[data-testhook-id="accordion-body-item"] > div > div').its('length').as('versions')
Now if I add the following assertion, this passes without any problem
cy.get('#versions').should('equal', 4)
But if I try to use the outcome of the number of div's found as a variable in a console.log I no longer get '4' but [object, Object]. Tried this by:
var size = cy.get('[data-testhook-id="asset-versions"] [data-testhook-id="accordion-body-item"] > div > div').its('length')
console.log('foo ' + size)
Which results in foo [object Object] being printed to the console.
What I want to do is use the number of items in a selector to select an element, like:
cy.get('[data-testhook-id="accordion-body-item"] > div > div:nth-child(' + size + ')').find('svg').should('have.attr', 'data-testhook-id', 'icon-active-version')
But as the var is not a number I get the msg
Error: Syntax error, unrecognized expression: :nth-child
[data-testhook-id="asset-versions"] [data-testhook-id="accordion-body-item"] > div > div:nth-child([object Object])
Is it possible to use the number of elements found as a variable for a next selector?
Try this:
cy.get('[data-testhook-id="accordion-body-item"] > div > div').its('length').then((size) => {
cy.get('[data-testhook-id="accordion-body-item"] > div > div:nth-child(' + size + ')').find('svg').should('have.attr', 'data-testhook-id', 'icon-active-version')
});
You cannot assign or work with the return values of any Cypress command. Commands are enqueued and run asynchronously. What commands really return are Chainable<typeOfValueYouWant>, in another words, it's kind of queue object which resolves with desired value.
Read more here
BTW: I think you should consider change your approach for selecting elements. Read more here.
For those who are using Typescript - I wrote plugin for tslint which prevents making this mistake: https://github.com/krzysztof-grzybek/tslint-plugin-cypress

change fancytree html node structure

Is it possible to change the html node structure ?
<span role="button" class="fancytree-expander"></span>
<span class="fancytree-title">
<div class="title">Direction Générale des Services</div>
<div class="agents">
<span class="agent">Directeur Général des Services<br>Jean-Marc Lucas<br><i class="fa fa-fw fa-phone"></i> : 02 96 13 59 59<br><i class="fa fa-fw fa-envelope"></i> contact#gp3a.bzh</span>
</div>
</span>
to
<span role="button" class="fancytree-expander"></span>
<span class="fancytree-title">
<div class="title">Direction Générale des Services</div>
</span>
<div class="agents">
<span class="agent">Directeur Général des Services<br>Jean-Marc Lucas<br><i class="fa fa-fw fa-phone"></i> : 02 96 13 59 59<br><i class="fa fa-fw fa-envelope"></i> contact#gp3a.bzh</span>
</div>
in other words, is it possible to add html node outsite of the span.fancytrre-title ?
Thx
Have a look at the Fancytree events, especially createNode and renderTitle.
Example:
function createNode(event, data) {
// add fake <input/> to the node
var $input = $("<input/>").val(data.node.title);
$("span.fancytree-title", data.node.li).before($input);
}

Selenium- Tag traversal Xpath for facebook First name not working

<div id="reg_form_box" class="large_form">
<div class="clearfix _58mh">
<div class="mbm _3-90 lfloat _ohe">
<div id="u_0_0" class="_5dbb">
<div class="uiStickyPlaceholderInput uiStickyPlaceholderEmptyInput">
<div class="placeholder" aria-hidden="true">First name</div>
<input id="u_0_1" class="inputtext _58mg _5dba _2ph-" data-type="text" name="firstname" aria-required="1" placeholder="" aria-label="First name" aria-controls="js_0" aria-haspopup="true" role="null" aria-describedby="js_w" aria-invalid="true" type="text"/>
</div>
<i class="_5dbc img sp_beZQzZ7Rg6Q sx_5ca7f2"/>
<i class="_5dbd img sp_beZQzZ7Rg6Q sx_9c246c"/>
</div>
Above is the code for which i want to write Xpath using tag name traversal. Here is the xpath i have made
"//div[#id='reg_form_box']/div[1]/div[1]/div[1]/div/input"
Please suggest what's wrong here and how can i correct the same. Website is Facebook and field is First name on homepage.
Ideally unless you have a case of multiple modes that match the same xpath, you don't have to traverse through the entire hierarchy.
This will work:
//input[#name='firstname']

Perl Scrappy select using class attribute

I was trying to scrape using Perl Scrappy. I would like to select html elements with class attribute using 'select'.
<p>
<h1>
<a href='http://test.com'>Test</a>
<a href='http://list.com'>List</a>
</h1>
</p>
<p class='parent-1'>
<h1>
<a class='child-1' href="http://sample.com">SampleLink</a>
<a class='child-2' href="http://list.com">List</a>
</h1>
</p>
I need to get element('a' tag) with class name 'child-1' which is a child nod of <p class='parent-1'> using select method.
I have tried like this
#!/usr/bin/perl
use Scrappy;
my $scraper = Scrappy->new;
$scraper->get($url);
$scraper->select('p a')->data;
But it will select the first 'p' tag also.
Could you please help me with this?
Bearing in mind choroba's warning, to select an <a> element with a class of child-1 that is a child of a <p> element with a class of parent-1 you would write
$scraper->select('p.parent-1 > a.child-1')
The problem is that in HTML, a <p> tag can't contain a <h1> tag. In fact, the HTML is parsed as
<p></p>
<h1>
<a href='http://test.com'>Test</a>
<a href='http://list.com'>List</a>
</h1>
<p class='parent-1'></p>
<h1>
<a class='child-1' href="http://sample.com">SampleLink</a>
<a class='child-2' href="http://list.com">List</a>
</h1>