How do you extract an attribute value from and element with iMacros? - web-scraping

I'm trying to record a macro that can extract a value from a target element.
This is what I tried... but it didn't work :(
TAG POS=1 TYPE=DIV ATTR=ID:foo EXTRACT=ARIA-EXPANDED
I also saw some docs that made it look like this would work:
TAG POS=1 TYPE=DIV ATTR=ID:foo&&ARIA-EXPANDED:* EXTRACT=ARIA-EXPANDED
No luck so far...

You may try like so:
TAG POS=1 TYPE=DIV ATTR=ID:foo&&ARIA-EXPANDED:* EXTRACT=HTM
SET attr EVAL("'{{!EXTRACT}}'.match(/aria-expanded=[\"'](.+?)[\"']/)[1];")

Related

Why use attrs in Beautiful Soup for scraping

for link in soup.find_all(attrs={'class': 'title"'}):
for links in link.find_all('a'):
If I use attrs, then links are scraped, but if I use tag, then they are not scraped. So what's the difference between attrs and tag?
Main difference between tag and attribute / attrs is that a tag represents an element, while an attribute describs the characteristics of an element.

How to access embedded data in custom css

In the Look & Feel section of a survey, under Advanced, you can Add custom css.
I'd like to access my embedded data in my custom css.
For example, I would like to do this:
.Skin {
font-family: ${e://Field/fontFamily};
}
The above code doesn't work. The embedded data variable fontFamily isn't inserted into the custom css.
I am able to access embedded data in the Header and Footer elements. However, these elements do not allow me to specify styles for the rest of the document (qualtrics seem to strip any elements you add to that section).

CSS - How can I select this <tr>?

HTML (clicky click)
I need to select this tr using only CSS, I can't use the ID because i need to select the last tr in this section for every subforum - and all the IDs are different.
Try using a class.
From what you are saying, it looks like you want to select each item with a <tr> tag at the bottom. In the tag add class="<your custom class here>". (Ex: class="bottomtr") In the CSS code, using .<your custom class here> style it how you want. It is just like any other selector in CSS and can be formatted the same way.

Define Base-URL for img src via CSS

Is it possible to define the base URL used for <img>-tags of a certain class via CSS?
For example my <img>-tag would look like
<img class="switchingURL" src="pic1.png">
Then I'd like a kind of CSS element like:
.switchingURL {base-url: /images/;}
Then if I want another picture set, I'd rewrite it to something like:
.switchingURL {base-url: http://www.tempsite.de/newstyle/images/;}
Does a tag similar to the base-url I used in the examples above exist?
SEARCH NO MORE , you can not do that with css .
but it's your lucky day , with a simple line of jquery you can do that .
$('img[src=""]').attr("src", "images/someimg.jpg")
the above line searches for empty src and sets it to images/someimg.jpg

Css Content attribute with elements

I am working on a small project.
I wish to add an anchor tag <a> inside another element using the css content attribute and the :after pseudo.
e.g.
.classname:after { content: '<a>hello</a>'; }
// this will print "<a>hello</a>"
What I need it to do is make it have a working anchor tag, pointing to a given href.
I know you can use something like this content: attr(title); so it will use .classname title attribute as a text, I don't know if this is even possible but, it would be cool if it was.
You can't use the CSS :before and :after pseudo-elements to insert HTML elements. To add HTML elements you need to use JavaScript.
You cant im afraid. You have to use javascript :(
A quick example of putting a link into a p with the id of myP tho... and a variable for a url (which could be obtained from any value really)...
var myUrl = "http://www.glcreations.co.uk";
document.getElementById("myP").innerHTML = "<a href='" + myUrl + "'>A link for you to click on</a>";

Resources