code4craft / code4craft/xsoup

Fetch value from inside an attribute

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
474
Forks
148
PR merge metrics
No merged PRs in 30d

Description

Here is an html from one of the webpages i am parsing
<section class="property-header
                         " data-locale="de-DE" data-campsite-data="{&quot;id&quot;:2645,&quot;property_id&quot;:2645,&quot;property_name&quot;:&quot;Erzgebirgscamp Neuclausnitz&quot;,&quot;premium&quot;:false,&quot;amenities&quot;:&quot;[\&quot;WiFi\&quot;, \&quot;Free WiFi\&quot;]&quot;,&quot;activities&quot;:&quot;[\&quot;Cycle tracks\&quot;,\&quot;Hiking\&quot;,\&quot;Playground\&quot;,\&quot;Soccer\&quot;,\&quot;Mountainbiking\&quot;,\&quot;Cross-country skiing\&quot;]&quot;,&quot;leisure&quot;:&quot;[\&quot;Washing-up area\&quot;,\&quot;Washing machines\&quot;,\&quot;Tumble dryer\&quot;,\&quot;Washbasins\&quot;,\&quot;Shower cubicles\&quot;,\&quot;Heated sanitary facilities\&quot;,\&quot;Shared barbecueing area\&quot;,\&quot;Bread delivery\&quot;]&quot;,&quot;utilities&quot;:&quot;[\&quot;Guest boat moorings\&quot;,\&quot;Firewood available\&quot;,\&quot;Electric bike charging station\&quot;]&quot;,&quot;rules&quot;:&quot;[\&quot;Dogs Allowed\&quot;,\&quot;Barbecueing On Pitch Allowed\&quot;,\&quot;Car On Pitch Allowed\&quot;]&quot;,&quot;slug&quot;:&quot;erzgebirgscamp-neuclausnitz&quot;,&quot;coordinates&quot;:&quot;(50.7411,13.516)&quot;,&quot;distance&quot;:&quot;3594.66454744824&quot;,&quot;zip&quot;:&quot;09623&quot;,&quot;town&quot;:&quot;Rechenberg-Bienenm\u00fchle&quot;,&quot;latitude&quot;:50.7411,&quot;longitude&quot;:13.516,&quot;street&quot;:&quot;Hauptstra\u00dfe 25&quot;,&quot;city_id&quot;:16,&quot;city_slug&quot;:&quot;sachsen&quot;,&quot;city&quot;:&quot;Sachsen&quot;,&quot;country&quot;:&quot;Deutschland&quot;,&quot;country_slug&quot;:&quot;de&quot;,&quot;currency&quot;:&quot;EUR&quot;,&quot;rating&quot;:&quot;5&quot;,&quot;podio_id&quot;:508050624,&quot;older_children_lower_age_limit&quot;:6,&quot;older_children_upper_age_limit&quot;:17,&quot;younger_children_lower_age_limit&quot;:0,&quot;younger_children_upper_age_limit&quot;:5,&quot;photo&quot;:&quot;https:\/\/intcamp-eu-west-1-live01-public.s3-eu-west-1.amazonaws.com\/de-live\/gallery_970x545_270661681-campsite.jpg,https:\/\/intcamp-eu-west-1-live01-public.s3-eu-west-1.amazonaws.com\/de-live\/gallery_970x545_270661691-campsite.jpg,https:\/\/intcamp-eu-west-1-live01-public.s3-eu-west-1.amazonaws.com\/de-live\/gallery_970x545_270661694-campsite.jpg&quot;,&quot;availability&quot;:{&quot;9962&quot;:{&quot;is_available&quot;:true,&quot;has_instant_booking&quot;:true,&quot;pitch_type&quot;:&quot;[\&quot;Motorhome\&quot;]&quot;},&quot;9959&quot;:{&quot;is_available&quot;:true,&quot;has_instant_booking&quot;:true,&quot;pitch_type&quot;:&quot;[\&quot;Tent\&quot;]&quot;},&quot;9960&quot;:{&quot;is_available&quot;:true,&quot;has_instant_booking&quot;:true,&quot;pitch_type&quot;:&quot;[\&quot;Tent\&quot;]&quot;},&quot;9961&quot;:{&quot;is_available&quot;:true,&quot;has_instant_booking&quot;:true,&quot;pitch_type&quot;:&quot;[\&quot;Caravan\&quot;]&quot;},&quot;9963&quot;:{&quot;is_available&quot;:true,&quot;has_instant_booking&quot;:true,&quot;pitch_type&quot;:&quot;[\&quot;Motorhome\&quot;]&quot;}},&quot;instant_booking&quot;:true,&quot;category&quot;:&quot;Regul\u00e4r&quot;,&quot;address&quot;:&quot;Hauptstra\u00dfe 25, 09623 Rechenberg-Bienenm\u00fchle, Sachsen, Deutschland&quot;,&quot;slashed_price&quot;:null,&quot;coordinatesShow&quot;:&quot;50.741, 13.516&quot;}" data-all-pitches="{&quot;tent&quot;:&quot;Zelt&quot;,&quot;caravan&quot;:&quot;Wohnwagen&quot;,&quot;motorhome&quot;:&quot;Wohnmobil&quot;,&quot;cabin&quot;:&quot;Mietunterkunft&quot;}" data-price-request="price" data-currency-code="EUR">
<div class="row">
<div class="col-xs-12 col-sm-9">
<h1 itemprop="name">Campingurlaub auf dem Erzgebirgscamp Neuclausnitz</h1>
</div>
<div class="col-sm-3 text-right label-instant-wrapper">
<span class="label-instant">
<i class="icon-ic_flash"></i>
Sofortbuchung</span>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-9">
<div class="property-address" itemprop="address" itemscope="" itemtype="https://schema.org/PostalAddress">
<span itemprop="streetAddress">Hauptstraße 25, 09623 Rechenberg-Bienenmühle, Sachsen, Deutschland</span>
<meta itemprop="addressCountry" content="Deutschland">
<meta itemprop="postalCode" content="09623">
</div>
<a class="property-address" target="_blank" href="//google.com/maps/search/Erzgebirgscamp+Neuclausnitz/@">
Hauptstraße 25, 09623 Rechenberg-Bienenmühle, Sachsen, Deutschland </a>
</div>
<div class="col-xs-12 col-sm-9 col-lg-3 rating-wrapper">
<span class="rating-number">5,0</span>
<span class="rating-stars icon-ic-11-ratings"></span>
<a class="rating-popup-link rating-popup-link-desktop" href="#" data-property-id="2645">(Bewertungen)</a>
<a class="rating-popup-link rating-popup-link-mobile" href="#" data-property-id="2645" data-more="(Bewertungen)" data-less="(Bewertungen ausblenden)">(Bewertungen)</a>
</div>
</div>
</section>

Q: I need to fetch the value inside data-campsite-data

On Firefox Firepath this works: //@data-campsite-data

What would be its equivalent using xsoup

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by checking xsoup's documented attribute-selection or XPath entry points and reproduce the supplied HTML example. Done means the documented usage reliably returns the value of data-campsite-data.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.