Adding live population to my Html website from worldometers.info - html

I have a website that shows the user the population for the country in an attractive way.
My problem is that I will need to get the data to be updated automatically.
My question is how do I get the source code of the population from this website.
https://www.worldometers.info/world-population/afghanistan-population/

You can use the following free API to get the current population of the country. Then you can use JavaScript to fetch the value and output it on your website. To always display the latest value, you could wrap the fetch method in an interval, which repeats after a given time.

Related

Sort numbers by string

Hi I am using an API from Postcode Anywhere, the idea being to add a company by searching by postcode to select the address, this is pretty standard and the code works fine.
Just some background info, PAW works in two stages, 1 the post code search criteria is sent off to their services, which returns an array of possible addresses, you then select the address you want, and in stage 2, the full PAF file for that ID is returned and stored to the table.
The problem I am having is that the array they send includes an Address Field which includes house number and street address in one field, making it difficult to sort alphanumerically.
This is the sample data I have in my table:
and this is how it looks in my application:
As you can see it is not ideal and I have no control on how they send the data.
Does anyone have any ideas on how I can search a string based on numbers that can be 1, 11, 2, instead of 01, 02, 03, etc, or at the very least be able to split this into two rows. Also please note, that it most cases, the post code search will result business/property names as well as house numbers, as seen in this example.
Any thoughts would be greatly appreciated.
Have you considered using a different API provider for the data, Allies Computing (who I work for) have a single step API, where the initial postcode search returns all fields in the response. It also orders these results by premise number/name.
Give it a try here - https://developers.alliescomputing.com/postcoder-web-api/address-lookup/premise
There are also other providers of PAF data that do it this way such as Crafty Clicks and Ideal Postcodes.
It might also be worth checking the PAF license with your provider to ensure you comply with that too.

OSM to CSV with OSMCONVERT gives my "empty" amenities

I'm trying to convert my country's Open Street Map data to a CSV file which I can then load in tableau and map businesses.
I downloaded osmconvert, which seems to be the default tool for this process.
Then I downloaded the Dominican Republic's data from this URL:
http://download.geofabrik.de/central-america/haiti-and-domrep.html
When I run the following command:
osmconvert64.exe data.osm --csv="#id #lon #lat #amenity #name #shop" --csv-headline --csv-separator=, -o=outfile.csv
I get a sheet like this:
Picture of excel sheet with empty columns
I seem to get the ID, Latitude and Longitude data right, but get empty amenity, name, and shop columns.
Am I writing the command wrong? I'd appreciate any help, since I can't seem to find an user-friendly tutorial on using this tool on the internet.
I'm not very familiar with osmconvert but as far as I know it will generate an entry for each element in the input file. Most elements from the input file won't have a amenity, name or shop tag. That's why you get so many empty columns. I guess you have to specify an additional filter to get only elements with an amenity or shop tag, possibly with the help of osmfilter.
Alternatively just use Overpass API and perform a simple query for all elements with an amenity or shop tag. Overpass API is also able to generate CSV output.

how to add a container/widget/simple widget/vtl file dynamically in dotCMS

Scenario:
I have an autocomplete country widget. So when:
I start typing a country name in the textbox, the countries that match that query appears. Lets say I type "Co" and it shows me "Colombia" and "Congo" in a list.
Then I select "Congo".
When I select Congo I want to call a Widget/Container/vtl file/whatever that brings me the information I want formatted the way the widget is formatted. Lest say, all the info of the Congo, Location, Population, a brief description, etc.
I tried with the RestAPI and thought of using dotParse()? But I'm new on this I have no idea if this is even possible. I searched in the docs, but didn't find anything similar.
So how can I do this possible?
I have the Widget created, do I only need to call it via the RestApi?
Do I have to create a Container first?
Thanks in advance, for your help.
Thanks i
It sounds like what you want is the RESTful widget API. This is a remote call that will return your widget rendered. See:
http://dotcms.com/docs/latest/WidgetAPI
and
http://dotcms.com/docs/latest/remote-widgets

xpath finds element in developers console but not in scrapy.response

I'm trying to scrape the price from the first ticket here page using this xpath:
'.//*[#class="price"]/text()'
This works in the developer's console, but not when I run it in the scrapy shell using response.xpath. I have also tried to following in the shell:
'.//*[#class="initial"]/div[#class="price"]/text()'
and
'//*[#id="tVB901769989"]/div[1]/div[4]' (although I don't think that the id property can be used in the shell like this).
Is there something wrong with the xpaths that I've used, or is there some thing different with the way the page works? Any help would be appreciated. Thanks!
this happens because you are checking at different requests, the page you see doesn't have the information you need inside that file, but it gets it dynamically, in this case from: www.vividseats.com/javascript/tickets.shtml?productionId=1771684
There you can check the prices on json format, I think this is for one item:
{
"s":"Section 111",
"r":"8-22",
"q":"4",
"p":"692.00",
"i":"VB782041491",
"d":"111",
"n":"Zone Seating. The seller is committing to procure these tickets for you upon receipt of your order. After you place your order and your order is confirmed, we guarantee that your tickets will be within the listed zone
or section listed or one comparable and that you will receive these tickets in time for the event or
your money back. Orders exceeding four tickets may be split up into different rows within the requested
zone or section.",
"f":"0",
"l":"Section 111",
"g":"0",
"e":"0",
"h":"07/21/15",
"t":"0",
"v":"",
"c":"84352",
"z":"1",
"rhdn":"0",
"ind":"0",
"sd":"0"
}
where p contains the price.

Search in specific country only?

So, starting with the following query, I can pass user input to the Geocode API and return a json object/response with the locations details.
http://maps.googleapis.com/maps/api/geocode/json?address=10010
My problem is I have the following query with component filters with the country set to the US (United States). However, if you enter in a zipcode like this which is returning an area in Russia it still renders the map and sets the marker for the users current location.
http://maps.googleapis.com/maps/api/geocode/json?address=16721**&components=country:US**&sensor=false
Do I need to check the short_name within the returned object in a simple if statement and choose whether to issue a map request or not?
I thought component filters would restrict the user to search within the country specified? Then, return ZERO_RESULTS if there is not a match.
Any input, feedback is welcomed. Thanks!
Remove stars from from country name:
http://maps.googleapis.com/maps/api/geocode/json?address=16721**&sensor=false&components=country:US