Trying to get 9 consecutive HTML tags












0















I am running the following code and getting all nulls, which can't be correct.



for link in page_source:
wd.get(link)
#print(link)
html_page = wd.page_source
soup = bs(html_page, 'html.parser')
for a in soup.find_all('a', {'href':re.compile('_id=')}):
link_text = a['href']

if '/admin/airflow/tree?dag_id=' in link_text and '&num_runs=' not in link_text:

ID = re.match('(.*)_id=(w+)', link_text).group(2)

cir1 = soup.find_all('circle')[0].text
cir2 = soup.find_all('circle')[1].text
cir3 = soup.find_all('circle')[2].text
cir4 = soup.find_all('circle')[3].text
cir5 = soup.find_all('circle')[4].text
cir6 = soup.find_all('circle')[5].text
cir7 = soup.find_all('circle')[6].text
cir8 = soup.find_all('circle')[7].text
cir9 = soup.find_all('circle')[8].text

print(id+'|'+cir1+'|'+cir2+'|'+cir3+'|'+cir4+'|'+cir5+'|'+cir6+'|'+cir7+'|'+cir8+'|'+cir9)


Result:



barra_cae5_daily_smgm|||||||||


Here's in the HTML behind the page I'm working with.



enter image description here



There are up to 9 circle tags for each ID in 'link_text'in each row. Then I'm moving to the next row, getting the next ID, and all circle tags, and so on and so forth. How can I grab these 'circle' tags? Thanks.










share|improve this question


















  • 1





    Don't post pictures of code.

    – Robert Harvey
    Jan 2 at 16:25











  • Since I don't actually got the real page it's hard to provide good help or actually verify any result. A couple of things to look out for is if the page is client-side rendered (can not see if so is the case since I can't see the actual page), this looks like embedded svg which might behave differently as well. If you are working with a SPA/client side rendered page you can use for instance Requests-HTML to render and then parse pages.

    – Hultner
    Jan 2 at 16:36











  • I don't think there is a problem with the parsing; I'm getting the ID just fine. I just can't tell if I'm looking for the right tags for the circle. When I try this: cir1 = soup.find_all('transform')[0].text I get: IndexError: list index out of range When i try this: cir1 = soup.find_all('circle')[0].text Nothing is returned, but I really think I should get a '3' because that's the text for the fist circle tag.

    – ryguy72
    Jan 2 at 16:40













  • Oh, I got it. It's the 'text' tag not the 'circle' tag. cir1 = soup.find_all('text')[0].text cir2 = soup.find_all('text')[1].text cir3 = soup.find_all('text')[2].text

    – ryguy72
    Jan 2 at 19:31


















0















I am running the following code and getting all nulls, which can't be correct.



for link in page_source:
wd.get(link)
#print(link)
html_page = wd.page_source
soup = bs(html_page, 'html.parser')
for a in soup.find_all('a', {'href':re.compile('_id=')}):
link_text = a['href']

if '/admin/airflow/tree?dag_id=' in link_text and '&num_runs=' not in link_text:

ID = re.match('(.*)_id=(w+)', link_text).group(2)

cir1 = soup.find_all('circle')[0].text
cir2 = soup.find_all('circle')[1].text
cir3 = soup.find_all('circle')[2].text
cir4 = soup.find_all('circle')[3].text
cir5 = soup.find_all('circle')[4].text
cir6 = soup.find_all('circle')[5].text
cir7 = soup.find_all('circle')[6].text
cir8 = soup.find_all('circle')[7].text
cir9 = soup.find_all('circle')[8].text

print(id+'|'+cir1+'|'+cir2+'|'+cir3+'|'+cir4+'|'+cir5+'|'+cir6+'|'+cir7+'|'+cir8+'|'+cir9)


Result:



barra_cae5_daily_smgm|||||||||


Here's in the HTML behind the page I'm working with.



enter image description here



There are up to 9 circle tags for each ID in 'link_text'in each row. Then I'm moving to the next row, getting the next ID, and all circle tags, and so on and so forth. How can I grab these 'circle' tags? Thanks.










share|improve this question


















  • 1





    Don't post pictures of code.

    – Robert Harvey
    Jan 2 at 16:25











  • Since I don't actually got the real page it's hard to provide good help or actually verify any result. A couple of things to look out for is if the page is client-side rendered (can not see if so is the case since I can't see the actual page), this looks like embedded svg which might behave differently as well. If you are working with a SPA/client side rendered page you can use for instance Requests-HTML to render and then parse pages.

    – Hultner
    Jan 2 at 16:36











  • I don't think there is a problem with the parsing; I'm getting the ID just fine. I just can't tell if I'm looking for the right tags for the circle. When I try this: cir1 = soup.find_all('transform')[0].text I get: IndexError: list index out of range When i try this: cir1 = soup.find_all('circle')[0].text Nothing is returned, but I really think I should get a '3' because that's the text for the fist circle tag.

    – ryguy72
    Jan 2 at 16:40













  • Oh, I got it. It's the 'text' tag not the 'circle' tag. cir1 = soup.find_all('text')[0].text cir2 = soup.find_all('text')[1].text cir3 = soup.find_all('text')[2].text

    – ryguy72
    Jan 2 at 19:31
















0












0








0


1






I am running the following code and getting all nulls, which can't be correct.



for link in page_source:
wd.get(link)
#print(link)
html_page = wd.page_source
soup = bs(html_page, 'html.parser')
for a in soup.find_all('a', {'href':re.compile('_id=')}):
link_text = a['href']

if '/admin/airflow/tree?dag_id=' in link_text and '&num_runs=' not in link_text:

ID = re.match('(.*)_id=(w+)', link_text).group(2)

cir1 = soup.find_all('circle')[0].text
cir2 = soup.find_all('circle')[1].text
cir3 = soup.find_all('circle')[2].text
cir4 = soup.find_all('circle')[3].text
cir5 = soup.find_all('circle')[4].text
cir6 = soup.find_all('circle')[5].text
cir7 = soup.find_all('circle')[6].text
cir8 = soup.find_all('circle')[7].text
cir9 = soup.find_all('circle')[8].text

print(id+'|'+cir1+'|'+cir2+'|'+cir3+'|'+cir4+'|'+cir5+'|'+cir6+'|'+cir7+'|'+cir8+'|'+cir9)


Result:



barra_cae5_daily_smgm|||||||||


Here's in the HTML behind the page I'm working with.



enter image description here



There are up to 9 circle tags for each ID in 'link_text'in each row. Then I'm moving to the next row, getting the next ID, and all circle tags, and so on and so forth. How can I grab these 'circle' tags? Thanks.










share|improve this question














I am running the following code and getting all nulls, which can't be correct.



for link in page_source:
wd.get(link)
#print(link)
html_page = wd.page_source
soup = bs(html_page, 'html.parser')
for a in soup.find_all('a', {'href':re.compile('_id=')}):
link_text = a['href']

if '/admin/airflow/tree?dag_id=' in link_text and '&num_runs=' not in link_text:

ID = re.match('(.*)_id=(w+)', link_text).group(2)

cir1 = soup.find_all('circle')[0].text
cir2 = soup.find_all('circle')[1].text
cir3 = soup.find_all('circle')[2].text
cir4 = soup.find_all('circle')[3].text
cir5 = soup.find_all('circle')[4].text
cir6 = soup.find_all('circle')[5].text
cir7 = soup.find_all('circle')[6].text
cir8 = soup.find_all('circle')[7].text
cir9 = soup.find_all('circle')[8].text

print(id+'|'+cir1+'|'+cir2+'|'+cir3+'|'+cir4+'|'+cir5+'|'+cir6+'|'+cir7+'|'+cir8+'|'+cir9)


Result:



barra_cae5_daily_smgm|||||||||


Here's in the HTML behind the page I'm working with.



enter image description here



There are up to 9 circle tags for each ID in 'link_text'in each row. Then I'm moving to the next row, getting the next ID, and all circle tags, and so on and so forth. How can I grab these 'circle' tags? Thanks.







python python-3.x






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 16:24









ryguy72ryguy72

4,5891824




4,5891824








  • 1





    Don't post pictures of code.

    – Robert Harvey
    Jan 2 at 16:25











  • Since I don't actually got the real page it's hard to provide good help or actually verify any result. A couple of things to look out for is if the page is client-side rendered (can not see if so is the case since I can't see the actual page), this looks like embedded svg which might behave differently as well. If you are working with a SPA/client side rendered page you can use for instance Requests-HTML to render and then parse pages.

    – Hultner
    Jan 2 at 16:36











  • I don't think there is a problem with the parsing; I'm getting the ID just fine. I just can't tell if I'm looking for the right tags for the circle. When I try this: cir1 = soup.find_all('transform')[0].text I get: IndexError: list index out of range When i try this: cir1 = soup.find_all('circle')[0].text Nothing is returned, but I really think I should get a '3' because that's the text for the fist circle tag.

    – ryguy72
    Jan 2 at 16:40













  • Oh, I got it. It's the 'text' tag not the 'circle' tag. cir1 = soup.find_all('text')[0].text cir2 = soup.find_all('text')[1].text cir3 = soup.find_all('text')[2].text

    – ryguy72
    Jan 2 at 19:31
















  • 1





    Don't post pictures of code.

    – Robert Harvey
    Jan 2 at 16:25











  • Since I don't actually got the real page it's hard to provide good help or actually verify any result. A couple of things to look out for is if the page is client-side rendered (can not see if so is the case since I can't see the actual page), this looks like embedded svg which might behave differently as well. If you are working with a SPA/client side rendered page you can use for instance Requests-HTML to render and then parse pages.

    – Hultner
    Jan 2 at 16:36











  • I don't think there is a problem with the parsing; I'm getting the ID just fine. I just can't tell if I'm looking for the right tags for the circle. When I try this: cir1 = soup.find_all('transform')[0].text I get: IndexError: list index out of range When i try this: cir1 = soup.find_all('circle')[0].text Nothing is returned, but I really think I should get a '3' because that's the text for the fist circle tag.

    – ryguy72
    Jan 2 at 16:40













  • Oh, I got it. It's the 'text' tag not the 'circle' tag. cir1 = soup.find_all('text')[0].text cir2 = soup.find_all('text')[1].text cir3 = soup.find_all('text')[2].text

    – ryguy72
    Jan 2 at 19:31










1




1





Don't post pictures of code.

– Robert Harvey
Jan 2 at 16:25





Don't post pictures of code.

– Robert Harvey
Jan 2 at 16:25













Since I don't actually got the real page it's hard to provide good help or actually verify any result. A couple of things to look out for is if the page is client-side rendered (can not see if so is the case since I can't see the actual page), this looks like embedded svg which might behave differently as well. If you are working with a SPA/client side rendered page you can use for instance Requests-HTML to render and then parse pages.

– Hultner
Jan 2 at 16:36





Since I don't actually got the real page it's hard to provide good help or actually verify any result. A couple of things to look out for is if the page is client-side rendered (can not see if so is the case since I can't see the actual page), this looks like embedded svg which might behave differently as well. If you are working with a SPA/client side rendered page you can use for instance Requests-HTML to render and then parse pages.

– Hultner
Jan 2 at 16:36













I don't think there is a problem with the parsing; I'm getting the ID just fine. I just can't tell if I'm looking for the right tags for the circle. When I try this: cir1 = soup.find_all('transform')[0].text I get: IndexError: list index out of range When i try this: cir1 = soup.find_all('circle')[0].text Nothing is returned, but I really think I should get a '3' because that's the text for the fist circle tag.

– ryguy72
Jan 2 at 16:40







I don't think there is a problem with the parsing; I'm getting the ID just fine. I just can't tell if I'm looking for the right tags for the circle. When I try this: cir1 = soup.find_all('transform')[0].text I get: IndexError: list index out of range When i try this: cir1 = soup.find_all('circle')[0].text Nothing is returned, but I really think I should get a '3' because that's the text for the fist circle tag.

– ryguy72
Jan 2 at 16:40















Oh, I got it. It's the 'text' tag not the 'circle' tag. cir1 = soup.find_all('text')[0].text cir2 = soup.find_all('text')[1].text cir3 = soup.find_all('text')[2].text

– ryguy72
Jan 2 at 19:31







Oh, I got it. It's the 'text' tag not the 'circle' tag. cir1 = soup.find_all('text')[0].text cir2 = soup.find_all('text')[1].text cir3 = soup.find_all('text')[2].text

– ryguy72
Jan 2 at 19:31














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009772%2ftrying-to-get-9-consecutive-html-tags%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009772%2ftrying-to-get-9-consecutive-html-tags%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory