i have an Array arr = [title, fileurl] so when i do print arr it goes like this:
['name1', 'url1']
['name1', 'url2']
['name1', 'url3']
['name2', 'url1']
['name2', 'url2']
['name3', 'url1']
I would like to group these array by the first element, it means I would like to have:
['name1', 'url1', 'url2', 'url3']
['name2', 'url1', 'url2']
['name3', 'url1']
My code:
for final in posterlink:
pagesourcec = requests.get(final)
soupc = BeautifulSoup(pagesourcec.text, "html.parser")
strc = soupc.findAll("iframe", attrs={"id": "myframe"})
title = soupb.find("li",{"class": "breadcrumb-item active"}).get_text()
for embedlink in strc:
fff = embedlink.get('data-src')
arr = [title, fff]
print arr
You can do this:
And if you absolutely want it as a list of lists, you can then follow up with this:
Edit: It's important to note that the above line works with python 3, which is what you should be using anyways. However, for the sake of completeness if you're using python 2.7, then use this: