Question

I am trying to capture all of the values for the data-hiringurl attributes on this page http://wearemadeinny.com/find-a-job/.

I tried var data = $("li").attr('data-hiringurl'); and var data = $("li").data('hiringurl'); in console, but got this TypeError: undefined is not a function

All of the data attributes are in <li> elements, but they do not have a common id.

Was it helpful?

Solution

You cannot do this since the content is coming via an iframe of another domain http://mappedinny.com/

<iframe src="http://mappedinny.com/" height="900" width="100%%" frameborder="0" scrolling="no"></iframe>

This is the error you should be getting when you try to access

$('iframe').contents().find('li[data-hiringurl]').val()
SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://wearemadeinny.com" from accessing a cross-origin frame.

Update:

If this for your own web-scraping purpose try disabling same origin policy in your browser configuration. Here are the links which will help you to disable same origin policy

Chrome: Disable same origin policy in Chrome

Firefox: Disable firefox same origin policy

OTHER TIPS

You can use:

var data = $("li[data-hiringurl]");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top