How to get Wikipedia content using Wikipedia's URL? - javascript

Is it possible to create an input field where you can paste a Wikipedia page link and it will get all the text contents from that page?
I'm trying to integrate a feature on my web application where people can paste their Wikipedia page link/URL they want to analyze on the input field. And the application will use that URL to get all the text content from that page.
Suppose the user inputs this link: https://en.wikipedia.org/wiki/Taylor_Swift
The application will return the text content of that page, like this:
Taylor Alison Swift (born December 13, 1989) is an American singer-songwriter. Her narrative songwriting, which often centers around her personal life, has received widespread media coverage. Born in West Reading, Pennsylvania, Swift relocated to Nashville, Tennessee in 2004 to pursue a career in country music. At age 14, she became the youngest artist signed by the Sony/ATV Music publishing house, and at age 15, she signed her first record deal. Her 2006 eponymous debut studio album was the longest-charting album of the 2000s on the Billboard 200. Its third single, "Our Song", made her the youngest .......
Also, I've tried this api, which works, but it just returns the header content, not the whole page content
I've gone through Wikipedia API and found none (yet). Any suggestions on how I do this?

Since you tagged node.js in your question, I'm assuming you are using Javascript. You could use an npm library called wikijs
An example from wikijs page
wiki({ apiUrl: 'https://es.wikipedia.org/w/api.php' })
.page('Cristiano Ronaldo')
.then(page => page.info())
.then(console.log);
Hope this works for you

You can use this API from Mediawiki to get the text of the article without any format:
https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&titles=Taylor_Swift
It's actually the same API you mentioned in your question, but the only difference that you should remove &exintro parameter, and add these two parameters instead &exlimit=max&explaintext

Related

Accessing API to download data without admin rights on Machine

I want to trial accessing an API without admin rights for my work machine - due to corporate setting.
I can't use Python as there is restricted access to the web.
It is possible to build a macro in excel, however this is not a preferred method.
Can you recommend any path forward.
An example API Endpoint URL: https://www.gov.uk/bank-holidays.json
Documentation of API: https://github.com/alphagov/calendars/blob/master/README.md
You can use powershell using the Invoke-Restmethod command, for example:
$data = Invoke-RestMethod https://www.gov.uk/bank-holidays.json
$data.'england-and-wales'.events
This returns a long list of the events in the "England and Wales" region
title
date
notes
bunting
New Year’s Day
2016-01-01
True
Good Friday
2016-03-25
False
Easter Monday
2016-03-28
True
...
...
...
...
After that you can manipulate the data however you want, its quite simple once you get the hang of it :)

Use company name to find exact linkedin url

Let's say I have 10 company names.
How to find their "nearly-exact" linkedin url?
ex.
A company is named "ABC Corp", its' linkedin url might be "https://www.linkedin.com/company/abc-corp"
but it's not accurate.
There's a way to improve the precision by use google to search linkedin+company name to find the result, but the error rate is still high.
is there any better solution?
The link you'd fetch would be https://www.linkedin.com/search/results/all/?keywords=COMPANY_NAME_HERE which searches for the company name.
Then, you can use beautiful soup to scrape the first result which is usually the company you are looking for
To do this via web/iOS/Android.
https://www.linkedin.com/help/linkedin/answer/3881/find-an-organization-s-page-on-linkedin?lang=en
Type the company, university, or high school name into the Search bar at the top of your LinkedIn homepage.
Click Companies or Schools at the top of the search results page.
Click Locations, Industry, or Company size to filter the results for a company. (optional)
Click on the correct organization name in the results list that appears.
To do this via the API
I'm assuming this is what you're looking for.
LinkedIn marketing API provides an Organization Search API for this use case. You can search using just keywords by calling the search API.
eg:
GET https://api.linkedin.com/v2/search?q=companiesV2&baseSearchParams.keywords=LinkedIn%20Corporation
However, if you happen to know information like the company's region/industry/company size etc. you can specify those as facets (think of these like filters)
eg:
GET https://api.linkedin.com/v2/search?q=companiesV2&baseSearchParams.keywords=LinkedIn%20Corporation&companySearchParams.facetIndustry%5B0%5D=6&companySearchParams.facetCompanySize%5B0%5D=H&companySearchParams.facetCompanyCountryRegion%5B0%5D=us:84
Documentation: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/organization-search

SMS Personalization using AMPScript in Salesforce Marketing Cloud

My CRM team is running into problems when attempting to personalize SMS using AMPScript. The syntax used is as follows:
%%[
Var #subscriberKey
Set #subscriberKey = _subscriberKey
]%%
%%= v(#subscriberKey) =%%
Thank you for signing up for a 45 day risk-free hearing aid trial! One of our expert hearing consultants will call you soon to discuss next steps. During this call, we'll discuss your hearing loss situation and go over the details of the 45 day risk-free trial. We look forward to speaking with you shortly!
I have created a data extension in Marketing Cloud with just me in it, and used it on a journey that sends a text message with this content to my phone. The text message delivers, however the personalization content is not in there, just the plain text is shown. Of course, once the personalization works, we will change it so that other information is in there and not subscriberKey, but for now it would be a ton of help to know why the syntax is not working when it should.
Kind regards,
Michael
you will need to add the personalized field i.e. First Name/ Subscriber Key/etc in the following format %%FirstName%% . This field is actually picked up from the Attributed which are linked in your Contact Builder. Look for Mobile Connect Demographics, make sure these attributes which are trying to add in personalization are present there.
Now next step is how to link your information from your Master DE to the MobileConnect Demographics, for that u need to create an Import Activity from Contact Builder, and Import these details in a Mobile Connect List.
Hope this helps.
Mobile Connect Lists are different from Emails Studio Lists - Keep this in mind.

Google Maps Api to find business name

I'm making a website for Italy service taxi, I want to replicate the autocomplete place search as in another website.
The other website uses Web Service API, I use Javascript API, but the Google Map library I think is the same....
For example if I write in other website: 'hotel president milano', it suggests me "NH Collection Milano President, Largo Augusto, 10, 20122 Milano, Italia", exactly what I want to know!
If I put in my website 'hotel president milano' I receive no suggestion! It only shows me the suggestion when I write "nh collection milano", if I change words position "collection nh milano" or "milano nh collection" I receive nothing.
If you look closely to the requests that are being made they are using another service https://developers.google.com/maps/documentation/javascript/places#place_search_requests
So the results you're basicly comparing oranges and apples here. Plus some of your search queries worked fine for me.

Standalone Javascript layout engine?

Assuming I retrieved HTML content from a website (over which I have no control), and that content contains lots of Javascript code that's a significant part of what's actually rendered by a layout engine (e.g. WebView).
Is there a way I can render it myself?
For example, in the extreme case, suppose I am visiting a website that has almost nothing in its but displays very rich TEXT content, via a host of Javascript functions (which obviously results in HTML).
How do access/read that HTML result?
I am looking to do this on Android only.
Update, trying to provide more context to #abesto. If you go to facebook.com and copy/paste rendered content into a text file, you'll receive:
Facebook logo
Email Password
Keep me logged in Forgot your password?
Facebook helps you connect and share with the people in your life.
Sign Up
It's free and always will be.
First Name:
Last Name:
Your Email:
Re-enter Email:
New Password:
I am:
Birthday:
Why do I need to provide this?
Security Check
This field is required.
Enter both words below, separated by a space.
Can't read the words below?Try different words or an audio captcha.
Please enter the words or numbers you hear.
Try different words or back to text.
Loading...
Text in the box:
What's this?
Back
Registering…
An error occurred. Please try again.
By clicking Sign Up, you are indicating that you have read and agree to the Terms of Use and Privacy Policy.
Create a Page for a celebrity, band or business.
* Română
* English (US)
* Español
* Português (Brasil)
* Français (France)
* Deutsch
* Italiano
* العربية
* हिन्दी
* 中文(简体)
* »
Facebook © 2011 · English (US)
Mobile · Find Friends · Badges · People · Pages · About · Advertising · Developers · Careers · Privacy · Terms · Help
But if you look at the actual source (what you get in HttpResponse) you'll see much more monstrous text... mostly javascript.
I am only interested in the result of that Javascript. Any ideas how to accomplish this?
I think the answer is yes, but don't do that.
If I had to implement a solution for translating 'Facebook' to a mobile phone, I could set up a server, maybe on Amazon EC2 and run the browser there, using a browser automation solution, such as Watir to simulate the clicks and scrape the data off the page. I think it's too much to hope for that you could run that efficiently behind the scenes on the phone itself.
However, the better solution might be to use Firebug/Fiddler etc to reverse engineer the ajax calls being sent and find a way to get the underlying data? Or maybe you just need to reverse-engineer the JS :(.
It sounds like you want something like this :
http://jsconsole.com/
You basically load the url and mess with it. You just need to hook something into it to do it programmatically.
Take a look at their remote debugging explanation.
Since it's hooked upto to your android over a stream you can use any old PC technology you want to sniff the HTML.

Categories

Resources