Scraping class by value returns `{xml_nodeset (0)}` - rvest

I'm trying to scrape a website https://everesting.cc/hall-of-fame/#/ to get names of riders.
I used a selector gadget to find a class value. It's supposed to be Rider__name. However, when I use the code below, it returns nothing. What am I doing wrong?
library(rvest)
everesting_html<- read_html("https://everesting.cc/hall-of-fame/#/")
html_nodes(everesting_html, ".Rider__name")

Related

Problem accesing a dictionary value on dialogflow fullfilment

I am using fullfilment section on dialogflow on a fairly basic program I have started to show myself I can do a bigger project on dialogflow.
I have an object setup that is a dictionary.
I can make the keys a constant through
const KEYS=Object.keys(overflow);
I am going through the values using
if(KEYS.length>0){
var dictionary = overflow[keys[i]]
if I stringify dictionary using
JSON.stringify(item);
I get:
{"stack":"overflow","stack2":"overflowtoo", "stack3":3}
This leads me to believe I am actually facing a dictionary, hence the name of the variable.
I am accesing a string variable such as stack and unlike stack3
Everything I have read online tells me
dictionary.stack
Should work since
JSON.stringify(item);
Shows me:
{"stack":"overflow","stack2":"overflowtoo","stack3":3}
Whenever I:
Try to add the variable to the response string.
Append it to a string using output+=${item.tipo};
I get an error that the function crashed. I can replace it with the stringify line and it works and it gives me the JSON provided so the issue isnt there
Dictionary values are created as such before being accessed on another function:
dictionary[request.body.responseId]={
"stack":"overflow",
"stack2":"overflowtoo",
"stack3":3 };
Based on the suggestion here I saw that the properties where being accessed properly but their type was undefined. Going over things repeatedly I saw that the properties where defined as list rather than single values.
Dot notation works when they stop being lists.
Thanks for guiding me towards the problem.

Universal-Aanalytics: Visitor.event() call is failing with label values

I am using universal-analytics for Google Analytics, but the visitor.event() call with label value as a string is not working.
As per the below document, it says the label value should be non-negative, does it mean it only accepts Integers or String as well?
https://github.com/peaksandpies/universal-analytics/blob/master/AcceptableParams.md
FYI:
visitor.event(category, action, label).send(); // Working and events are reported.
Example: {"category":"APISvc","action":"URLStats","label":"Called"}
visitor.event(category, action, label, labelValue).send(); // NOT Working.
Example: {"category":"APISvc","action":"URLStats","label":"Success","labelValue":"2S"}
Context: Using this in Cloud Functions (NodeJS) on Google Firebase.
Appreciating your help!
The value component, for a Google Analytics event, if it is defined it must be an integer (https://support.google.com/analytics/answer/1033068?hl=en).
Example:
{"category":"APISvc","action":"URLStats","label":"Success","labelValue":2}

Calling methods dynamically, but not from a custom class

I'm trying to create a simple loop that prints out all available values of dir("Hello") side by side with the help("Hello".xxx) for each dir returned.
I've seen a number of stackoverflow threads on calling functions dynamically from a custom class, but it's not so clear how I can loop through built-in methods.
Taking this as an example:
for dr in dir("Hello"):
Using 'format' converts the "Hello.%d" % dr into a string of "hello.upper", but the print(help('hello.upper')) fails, because the help function expects "hello".upper, not "hello.upper":
for dr in dir("Hello"):
print(dr)
print(help("Hello.%d" % dr))
I've tried researching getattr, but the help function is not a method of the string, so getattr("Hello", "help")("upper") isn't working either.
expected results are:
dir value (followed by:)
dir help output
help doesn't return a string, it opens an interactive viewer for reading the help page.
To view each of these pages for some object (warning: there are going to be a lot of these pages), you can use getattr to get the attribute of the object given its name
obj = "Hello"
for attr_name in dir(obj):
help(getattr(obj, attr_name))

Excel VBA copy the value of a label from Internet Explorer

I'm trying to retrieve the value "CONGE STATUTAIRE" from the following html code
<span class="DescriptionLabel" id="lblProjectDescription">CONGE STATUTAIRE</span>
I've tried this
nom_proj = IE.Document.getElementsByClassName("DescriptionLabel")(0).innerText
The code pass this line without problem but the the value of nom_proj is " ", and I would have hope to get "CONGE STATUTAIRE" for result.
Could anyone tells me what's wrong with it? The rest of my code is working i.e. I can retrieve value by using the getelementbyID method.
Any help will be welcomed.
I would use the getElementById() method, to make sure it can return only one HTML element and not a collection of objects:
nom_proj = IE.Document.getElementById("lblProjectDescription").innerText
However, the reason why you get "" is most probably that the collection returned by getElementsByClassName() has more than one element (often, when retrieving object by class names).
Which means: in the Document of your browser there will be most probably more elements that are styled with the CSS class DescriptionLabel; for example, something like this:
<div name="emptyRow" class = "DescriptionLabel"></div>
You can test if there are more than one element by:
1) either, adding a watcher to IE.Document.getElementsByClassName("DescriptionLabel");
2) or, printing all the elements inside, I bet my hat you'll find inside more than one:
For Each obj In IE.Document.getElementsByClassName("DescriptionLabel")
Debug.Print obj.InnerText
Next obj
GENERAL SUGGESTION: if an HTML object has an id, use the getElementByID; that method returns a single object, not a collection, so even if you would be sure that the collection will contain a unique element, it would anyway be less clean and efficient in terms of coding.

Django - Haystack in two differents apps

I am using Haystack in one app and its perfect. It is indexing everything that I need. But, now I created another app, with different model and content, and I would like to Haystack index it. The idea is to create two different "search" links on my website, one for each app.
However, when I add the second configuration to haystack index it, I get some problem...
I created a new search_index.py (inside my new app) with the following content:
import datetime
from haystack.indexes import *
from haystack import site
from oportunity.models import Oportunity
class OportunityIndex(SearchIndex):
title = CharField(document=True, use_template=True)
body = CharField()
date= DateTimeField()
def index_queryset(self):
return Oportunity.objects.filter(date=datetime.datetime.now())
site.register(Oportunity, OportunityIndex)
but, when I run python manage.py rebuild_index
I get the following error:
line 94, in all_searchfields
raise SearchFieldError("All SearchIndex fields with 'document=True' must use the same fieldname.")
haystack.exceptions.SearchFieldError: All SearchIndex fields with
'document=True' must use the same fieldname.
This is a known limitation of Haystack which has been discussed in a few different places where the underlying document store needs the document field to be consistently named across all search models.
It is documented in the haystack docs what the recommended document field name is. Bottom line, you can't define title = CharField(document=True) on one index and content = CharField(document=True) on another index, they have to be named the same.
BEST PRACTICE: name the index field text. This is recommended by the haystack docs and will give you the most compatibility with 3rd party apps.

Resources