Getting hyperlinks of a Wikipedia page using DBpedia - hyperlink

I have two resources in DBPedia: dbr:Diabetes_mellitus and dbr:Hyperglycemia. In Wikipedia, the corresponding pages are wikipedia-en:Diabetes_mellitus and wikipedia-en:Hyperglycemia.
In Wikipedia there is a hyperlink from Diabetes_mellitus page to Hyperglycemia page. But when I try to find the link between the 2 resources in DBpedia, I cannot find it.
I tried to find the link using the following SPARQL query.
SELECT ?prop WHERE {
{ dbr:Diabetes_mellitus ?prop dbr:Hyperglycemia }
UNION
{ dbr:Hyperglycemia ?prop dbr:Diabetes_mellitus }
}
But the answer is null. I get nothing as an answer.
Is there any way to find a link between the pages in DBpedia?
What I am trying to achieve is to get all the hyperlinks in any Wikipedia page. Is there any way I can achieve it?

As of May 2018, page links are stored in the <http://dbpedia.org/page_links> named graph.
Your query could be the following one:
SELECT ?prop
FROM <http://dbpedia.org/page_links> WHERE {
{ dbr:Diabetes_mellitus ?prop dbr:Hyperglycemia }
UNION
{ dbr:Hyperglycemia ?prop dbr:Diabetes_mellitus }
}
Try it!
Using ASK:
ASK
FROM <http://dbpedia.org/page_links> {
dbr:Hyperglycemia dbo:wikiPageWikiLink|^dbo:wikiPageWikiLink dbr:Diabetes_mellitus
}
Try it!

Related

Can I use IMPORTXML to scrape a Quora query into Sheets?

I am trying to scrape the results from a Quora search query using ImportXML.
The URL is of this form: https://www.quora.com/search?q=scrape%20Quora&time=year
I've tried using ImportXML, and can't get anything to work. As an example, I inspected the questions, and found they were inside a div with a class name of 'q-text puppeteer_test_question_title'. So I tried to import like this, but I just get #N/A:
importxml("https://www.quora.com/search?q=scrape%20Quora&time=year","//div[#class='q-text puppeteer_test_question_title']")
This is clearly not working: is there a fix or just not possible (and why)?
Thank you.
Quora (as of now) runs on JavaScript and google sheets import formulae do not support the scrapping of JS elements:
You can try to fetch the first 3 responses this way (quickly written, could be improved)
function myFunction() {
var options = {
'muteHttpExceptions': true,
'followRedirects': false
};
var url = 'https://www.quora.com/search?q=scrape%20Quora&time=year'
var jsonStrings = UrlFetchApp.fetch(url,options).getContentText().split('window.ansFrontendGlobals.data.inlineQueryResults.results["')
jsonStrings.forEach((jsonString,i) => {
if (i > 0) {
console.log(jsonString.split('"] = ')[1].split('\n')[0])
}
})
}
and then parse the complex json inside. However, other answers are transmitted by quora when scrolling down by ajax asynchronous request.

How to delete a field in Firestore document with flutter

I'm making a Flutter application.
But, I cannot delete a field in the Firestore document.
In another language I know to use FieldValue.delete() to delete a file in Firestorm document.
In Dart, How do I delete?
Update Oct,2018: This is Now Possible:
In order to delete a particular field from a Cloud Firestore document - make sure you are using Plugin version 0.8.0 or Above. Now a E.g If you have a document having a field 'Desc' with contain some Text. In Order to Delete it.
Firestore.instance.collection('path').document('name').update({'Desc': FieldValue.delete()}).whenComplete((){
print('Field Deleted');
});
This will Delete 'Desc' Field from the Document 'name'
I think this is currently impossible in standard, non hacky way.
There is an open issue https://github.com/flutter/flutter/issues/13905 in Flutter which have to be resolved first.
Get the DocumentReference, invoke update with a map which has a key you want to delete and value FieldValue.delete().
var collection = FirebaseFirestore.instance.collection('collection');
collection
.doc('document_id')
.update({
'field_to_delete': FieldValue.delete(),
}
);
Here is an official solution for deleting Field Path when programming in Flutter/Dart
Here is how a sample Firestore collection looks like:
{
'path': {
'name': {
'title': 'my title'
'description': 'my description',
}
}
}
In order to delete description field, you can do this:
Firestore.instance.collection('path').document('name').set(
{'description': FieldValue.delete()},
SetOptions(
merge: true,
),
)
And the collection will look like this:
{
'path': {
'name': {
'title': 'my title'
}
}
}
if you have nested fields then use the '.' (Dot) notation to specify the field.
E.g if your data is nested Map then this is handy.
Firestore.instance.collection('path').document('name').update({'address.town': FieldValue.delete()}).whenComplete((){
print('Field Deleted');
});

Dynamic Data To Google Sheet

I'm trying to pull dynamic data (form) to a google sheet.
I can't seem to find the right function.
I'm running this:
function name(){
return $('input[type="text"]').val();
}
I tried this:
function fullname(){
return $('#form-field-1-1').val();
}
No success for now.
I've attached the elements below.
Thank you [https://i.stack.imgur.com/Tt5Gk.png]
Your best choise is to use a Variable "DOM element" and capture it by ID. but if you prefer a custom JS this will do:
function(){
return document.getElementById('form-field-1-1').innerHTML;
}
Hope it helps.

React Native: how to get the names of all the albums

I would like the user to select an Album and then display the photos of it in react-native. There is the CameraRoll and it has the ability to filter by groupName, but I did not find a way of how to retrieve these groupNames. Does anybody know how to do this, or do I need to write a native plugin?
well, at least you can select a lot of items and group...
import R from 'ramda';
import { CameraRoll } from 'react-native';
let groupNames;
CameraRoll.getPhotos({
first:20000
}).then(
(result) => {
const groupNamesAr = R.map(
(item) => {
return item.node.group_name;
}
)(result.edges)
groupNames = R.countBy((i)=>i)(groupNamesAr);
}
)
Use this https://github.com/marcshilling/react-native-image-picker it will let you select an image from any album.
I don't think this is currently possible. See this issue in the official repository. You can upvote this feature request if you're looking for this to be implemented.
Simple answer is MediaLibrary.getAlbumsAsync()

How to parse article page links in rails with pismo and mechanic?

I'm trying to parse links on multiple-page articles to automatically click through them to extract the whole article content. I'm using mechanize, regarding to my last question and the helpful answer.
How can I search for pagination links? Each articles may have different link architectures, like:
ZEITONLINE:
<a id="hp.article.bottom.paginierung.2" class="pn-forward pn-button" title="Vor" href="http://www.zeit.de/politik/ausland/2013-01/Syrien-Fotografie-Reportage/seite-2">Vorwärts</a>
ARSTECHNICA:
<span class="next">Next <span class="arrow">→</span></span>
IGN:
Next »
For the IGN Link it's relatively simple to parse the link, because it contains the link text Next. But what about the other links? I know it should be doable, because pocket, readability and instapaper are extracting multiple page content.
Hope you can help me a bit.
I Write One Function For This
function proccessURL($ParentURL,$URL){
$parse_url=parse_url($URL);
if(#$parse_url['host']==""){
$Parent_URL=parse_url($ParentURL);
$path=explode("/",#$parse_url['path']);
$redirect=0;
$lkey=0;
$flag=false;
while(list($key,$val)=each($path)){
if($val==".." or $val=="." or $val=="..."){
$redirect++;
$lkey=$key;
$flag=true;
}else{
break;
}
}
if($flag){
$matches=explode("/",$Parent_URL['path']);
end($matches);
$b=each($matches);
$n=$b['key'];
$url='';
for($i=0;$i<$n-$redirect;$i++){
$url.=$matches[$i]."/";
}
for($i=$redirect+1;next($path);$i++){
$url.=$path[$i]."/";
}
rtrim($url,"/");
$parse_url['path']=$url;
}else{
$parse_url['path']="/".#$parse_url['path'];
}
}else{
$Parent_URL['scheme']=$parse_url['scheme'];
$Parent_URL['host']=$parse_url['host'];
}
//print_r($parse_url);
if(#$parse_url['query']!=""){
$parse_url['query']="?".#$parse_url['query'];
}
if(#$parse_url['fragment']!=""){
$parse_url['fragment']="#".#$parse_url['fragment'];
}
return $Parent_URL['scheme']."://".#$Parent_URL['host'].#$parse_url['path'].#$parse_url['query'].#$parse_url['fragment'];
}
This Function solve link Address
sample:
$CorrectLink=proccessURL("http://www.sepidarcms.ir/kernel/","../plugin/1.php");
The Output is "http://www.sepidarcms.ir/plugin/1.php"
Now You Can Parse Url By preg_match_all
$html="Your HTML Str";
$URL="Your HTML Page Link";
preg_match_all("/href=\"([^\"]*)\"/is", $html, $matches);
while(list($key,$val)=each($matches[1])){
$val=proccessURL($URL,$val);
echo $val;
}
This code List All href Url For You Correctly

Resources