Using Jsoup
I want to print the 기숙사 in the txt class
<ul class="">
<li class="top">
<span class="num">01</span>
<span class="txt">
<button onclick="frm_search.searchKeyword.value=$(this).text();frm_search.submit();">*기숙사*</button></span>
</li>
<li class="top">
<span class="num">02</span><span class="txt">
<button onclick="frm_search.searchKeyword.value=$(this).text();frm_search.submit();">졸업증명서</button></span>
</li>
</ul>
doc.select(""); What should be in Double quotes?
I guess that it should be: span:containsOwn(01) + span button
Element button = document.selectFirst("span:containsOwn(01) + span button");
String text = button.text();
See this Try.jsoup example to test and play around with different options.
This selector works by finding the span with the text "01", and then finding its sibling span (using the +) and then the child button element.
Related
I try this link
jSoup to check if a span class exists
but i want to get image url from the following script through jsoup.
<ul class="a-unordered-list a-nostyle a-button-list a-vertical a-spacing-top-micro">
<li class="a-spacing-small item"><span class="a-list-item">
<span class="a-declarative" data-action="thumb-action" data-thumb-action="{"variant":"MAIN","index":"0"}">
<span class="a-button a-button-selected a-button-thumbnail a-button-toggle a-button-focus"><span class="a-button-inner"><input class="a-button-input" type="submit"><span class="a-button-text" aria-hidden="true">
<img alt="" src="https://images-na.ssl-images-amazon.com/images/I/31XcCgGBePL._SS40_.jpg">
</span></span></span>
</span>
</span></li>
Try This :
Elements anchors = doc.select("li span img");
When navigating the site http://emich.edu on Android devices (with any browser), the sticky mobile navigation menu sticks to the bottom of the page if one clicks through to another page, scrolls to the bottom of that page, and clicks the back button. A picture of the issue is attached.
This should not happen; the nav should always be under the site header. We are using Foundation 6.3 and have tried several other versions. We have even tried Foundation outside of this site with no extra markup, and the same result is produced. I can't seem to find any other threads that describe a similar problem. Could it be a problem with Android?
The phones we have tested use Android v. 7.0 and 6.0.1.
To be clear, this problem does not happen on Apple devices nor PCs.
<header class="wide-image">
<div class="brand front-top">
<div class="row top-row" data-equalizer="branding">
<div class="large-4 medium-12 small-12 columns logo-combine" data-equalizer-watch="branding">
<div class="front-title">
<img src="{{f:57957}}" alt="Eastern Michigan University logo" />
</div>
</div>
<div class="large-8 medium-12 show-for-large columns" data-equalizer-watch="branding">
<div class="row idrow front">
<div class="small-12 columns secondary-nav">
<xsl:copy-of select="ou:includeFile('/_resources/inc/site-search.inc')" />
<ul id="quick-links-top">
<xsl:copy-of select="ou:includeFile('/_resources/inc/quick-links.inc')" />
<li id="search-glass"><span class="visuallyhidden">Search</span><i class="fa fa-search" aria-hidden="true"></i></li>
</ul>
</div>
</div>
</div>
</div>
<div id="site-title" class="row">
<div class="small-12 columns">
<ouc:div label="site-name" button-text="Site Name" group="_Admin" path="{$ou:siteroot}/_site/inc/name.pcf">
<xsl:if test="$ou:action = 'pub' and $ou:siteroot != '/'"><xsl:copy-of select="ou:includeFile(concat($ou:siteroot,'/_site/inc/name.inc'))" /></xsl:if>
</ouc:div>
</div>
<xsl:if test="($ou:topnav!='off')">
<div class="small-12 columns skip-main-nav">
<a class="show-on-focus show-for-sr" href="#maincontent">Skip Global Navigation</a>
</div>
</xsl:if>
</div>
<div data-sticky-container="">
<div data-sticky="" data-top-anchor="site-title:bottom" data-options="marginTop:0;" style="width:100%">
<div class="title-bar" data-responsive-toggle="example-animated-menu" data-hide-for="large">
<button class="menu-icon" type="button" data-toggle="offCanvasLeft" aria-expanded="false" aria-controls="offCanvasLeft">
<div class="visuallyhidden">Open/Close Menu</div>
</button>
<div class="title-bar-title" data-toggle="offCanvasLeft">Search & Navigation</div>
</div>
<!-- If top nav, add bar -->
<xsl:if test="$ou:topnav='on' or $ou:topnav='true' or $ou:topnav='1' or $ou:topnav='yes'"><!-- Top nav is truthy? -->
<div id="main-nav">
<div class="row show-for-large collapse">
<div class="small-12 columns">
<nav class="menu-box {if ($ou:action != 'pub') then 'omni-primary-nav' else ''}"><!-- 'omni-primary-nav' class used to style nav list within OUC preview -->
<ouc:div label="top-nav" button-text="Navigation" group="_Admin" path="{$ou:siteroot}/_site/inc/navigation.pcf">
<xsl:if test="$ou:action = 'pub'">
<xsl:text disable-output-escaping="yes"><? echo $navigation->primaryMenu; ?></xsl:text>
</xsl:if>
</ouc:div>
</nav>
</div>
</div>
</div>
</xsl:if>
</div>
</div>
</div>
...a bunch of XSL
</header>
It seems by default, the elements aren't sticky for small screens.
Sticky for small screens can be turned on by adding
data-options="stickyOn:small;"
or
data-sticky-on="small"
To the element data-sticky attribute.
Seems the reason it isn't sticky by default on "small" is to "save real estate".
Methinks it is this bug. See the workarounds mentioned there. Moving discussion there...
I have the following element in a webpage:
<div id="pnNij" class="post" data-tag1="" data-tag2="">
<a class="image-list-link" href="http://imgur.com/gallery/pnNij" data-page="0">
<img alt="" src="./Imgur_ The most awesome images on the Internet_files/H7fZCNgb.jpg">
<div class="point-info gradient-transparent-black transition">
<div class="relative">
<div class="pa-bottom">
<div class="arrows">
<div title="like" class="pointer arrow-up icon-upvote-outline" data="pnNij" type="image" data-up="4212"></div>
<div title="dislike" class="pointer arrow-down icon-downvote-outline" data="pnNij" type="image" data-downs="502"></div>
<div class="clear"></div>
</div>
<div class="point-info-points" title="points">
<span class="points-pnNij">3,710</span>
<span class="points-text-pnNij">points</span>
</div>
</div>
</div>
</div>
</a>
<div class="hover">
<p>Seems like 2017 has it all...</p>
<div class="post-info">
album · 69,542 views
</div>
</div>
</div>
notice how the href is equal to http://imgur.com/gallery/pnNij.
However, when I use JSoup to extract elements from the page like this:
docImgur = Jsoup.connect("http://imgur.com/").get();
Elements links = docImgur.getElementsByClass("post");
The element is almost extracted properly, except the href attribute is equal to /gallery/pnNij/
Why does the href attribute not contain the full URL?
When you check the page source, you'll find
<a class="image-list-link" href="/gallery/WRzti" data-page="0">
...
</a>
So the href attribute is not absolute, which results in your expected results: /gallery/WRzti
Solution
Use the abs: attribute prefix.
Example
Document docImgur = Jsoup.connect("http://imgur.com/").get();
Elements links = docImgur.select("a[href].image-list-link");
for (Element element : links) {
System.out.println(element.attr("abs:href"));
}
Output
http://imgur.com/gallery/WRzti
http://imgur.com/gallery/tCnDJ
http://imgur.com/gallery/JIHYh
...
<div class="item all clearfix">
<div class="pic all">
<a href="/terrace.jpg"/></a>
</div>
<div class="text all">
<a href="/link/test" class="title">
Some random title
</a>
<strong>STRONG TEXT</strong>
Some random subtitle…
</div>
</div>
I'm trying to get the text from the bold tag only, but whenever I parse it, it shows the complete. I also tried to remove the a class, but there was text left out below - "Some random subtitle".
I tried by:
Element strong_title = el.select("strong").first();
And then by retrieving strong_title.text().
Nevermind, it was a project-related code mistake.
The following code:
document.select("strong"); works just fine.
I started developing my first mobile app using jquery mobile.
So far it has been going nicely, but I am not able to solve a specific popup behaviour.
What I want it for a popup to show once the user loads the app. This popup should be similar to a add to home popup like you see in many apps. It is intended to point the users direction to the fixed footer with some important buttons. I managed to insert this popup and open it on page load, but there are two things I am not able to do.
My popup loads and disappears, which I want, and that is all OK. However, once you reload the page, or navigate to another and go back, it opens up again. This is annoying for the user. I would like it to open up only the first time you load the home page.
I would like to position the popup above the footer, so not over it, but above. How would I do this? Do I use x and y, and if yes how?
Is there a way for the overlay effect to obscure the whole page, except the footer?
Thank you.
Here is the code:
<div data-role="page" id="home">
<div data-position="fixed" data-role="header" data-theme="d">
<h1>Prva pomoć</h1>
<button data-icon="info" data-iconpos="right"></button>
</div>
<div data-role="content">
<ul data-role="listview" data-divider-theme="d">
<li data-role="list-divider">Ne reagira i ne diše
</li>
<li>Oživljavanje</li>
<li>Oživljavanje + AVD</li>
<li data-role="list-divider">Ne reagira, ali diše</li>
<li>Bočni položaj</li>
<li data-role="list-divider">Ostalo</li>
<li>Gušenje</li></ul></div>
<div id="popspot"></div>
<div data-role="popup" id="popup" data-transition="slidedown" data-position-to="#popspot" data-theme="a" data-overlay-theme="e" data-history="true">
<p>U slučaju hitnoće koristi ovaj izbornik!<p></div>
<script type="text/javascript" language="JavaScript">
$(":jqmData(role='page'):last").on("pageshow", function(event) {
$("#popup", $(this)).popup("open");
setTimeout(function(){
$("#popup").popup("close");
}, 3000);
});
</script>
<div data-role="footer" id="hitnizbor" data-position="fixed" class="nav-glyphish-example">
<div class="nav-glyphish-example" data-grid="b" data-role="navbar" data-theme="e">
<ul>
<li>Zovi Hitnu</li>
<li>Oživljavanje</li>
<li>Osobni podaci</li>
</ul>
</div>
You can use sessionStorage or localStorage to keep track of the information related to whether pop up is shown or not.
You code would be something as below
if (localStorage.popUpShown != 'true') {
// window will position the pop up to center
$('#popup').popup('open', {positionTo: 'window'});
localStorage.popUpShown = 'true';
setTimeout(function () {
$("#popup").popup("close");
}, 3000);
}
else{
// Can remove this alert in development enviornment.
alert('already shown the popup');
}
you can check the live fiddle here http://jsfiddle.net/mayooresan/MyaE9/
Also did some tweaking to your html. You had markup errors in your html page.
<div data-role="page" id="home">
<div data-position="fixed" data-role="header" data-theme="d">
<h1>Prva pomoć</h1>
<button data-icon="info" data-iconpos="right"></button>
</div>
<div data-role="content">
<ul data-role="listview" data-divider-theme="d">
<li data-role="list-divider">Ne reagira i ne diše</li>
<li>Oživljavanje
</li>
<li>Oživljavanje + AVD
</li>
<li data-role="list-divider">Ne reagira, ali diše</li>
<li>Bočni položaj
</li>
<li data-role="list-divider">Ostalo</li>
<li>Gušenje
</li>
</ul>
<div id="popspot"></div>
<div data-role="popup" id="popup" data-transition="slidedown" data-position-to="#popspot" data-theme="a" data-overlay-theme="e" data-history="true">
<p>U slučaju hitnoće koristi ovaj izbornik!</p>
</div>
</div>
<div data-role="footer" id="hitnizbor" data-position="fixed" class="nav-glyphish-example">
<div class="nav-glyphish-example" data-grid="b" data-role="navbar" data-theme="e">
<ul>
<li>Zovi Hitnu
</li>
<li>Oživljavanje
</li>
<li>Osobni podaci
</li>
</ul>
</div>