BeautifulSoup - Generate an ordered list of header elements (like a table of contents) [closed] - beautifulsoup

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm looking to somewhat generate a "table of contents" of sorts with BeautifulSoup. I've tried extracting the h1, h2, and h3 tags and building a string accordingly, but I'm struggling because I retain the tag content. I'm also struggling in general to get the format correct. Here's what I want.
Let's say I have a file, test.html
<h1>First Part<h1>
<h2>First sub Part<h2>
<h3>First sub sub part<h3>
<h1>Second Part<h1>
<h2>Second sub Part<h2>
<h3>Second sub sub part<h3>
Then, I want to end up generating the HTML that would give me this:
First part
First sub part
First sub sub part
The bullet's dont look great because of Stack's formatting (there may be functionality for this, but I'm not aware of how to use it), but you get the gist. Any ideas?
Thanks!

Related

How would I output just the first letter of each word from a string? Visual Basic [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am completing an NEA for my GCSE assessment, and need help with a certain piece of code.
The task requires me to create a music quiz in which the Artist of the song and the first letter of each word of the song title is displayed. I don't know how I would even start to do this. Currently I have the songs in an array from an external file and can output a random one based of a random number generator but need help manipulating the string.
Any help would be much appreciated,
Thanks.
You can read each character individually in VB.NET by accessing it as if it were an array. So if you have for example:
Dim s As String = "abcdef"
Then if you use brackets like it is an array you can return a single character.
So to get the first element would be:
Dim first_letter As String = s(0) ' This would return just "a" as it is the first item and arrays are 0 indexed
And to find each element you can do s(1), s(2) etc or whatever your string is called as a string is an array of characters so they can be accessed and manipulated like one.

vba code to search google using cell content as search criteria [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
firstly I can see that there is a vast amount of questions across multiple websites asking this same question, so please be patient with me as unfortunately the ones I have seen have either not been suitable or don't work and I am far from an expert.
to give you the full scenario - I have an xlsheet with a massive list of unique identifiers for products for the company I work for sells. I have to (at the moment) manually copy from the sheet to google to see its position in the results.
What would be great is to get a vba code that when I run it (hotkey it), automatically takes the cell contents and sends it into a google search so i effectively reduce my 3 clicks and ctrlV into one hotkey.
There's no need for VBA if all you want to do is open a Google search page one at a time.
With your search phrase in A1, use this formula, for example:
=HYPERLINK("http://www.google.com/search?q=" & A1,A1)
and fill down as far as required.
That will put a clickable link in column B, corresponding to the search phrase in column A.
Here is the code:
Sub Google_search()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate ("http://www.google.com/search?q=" & Cells(1, 1)) 'it will search for value, what is in column A1
IE.Visible = True
End Sub
Arrange the part Cells(1, 1) for the cell, what you really want to search.

VB.Net TextBox Equation Reader [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I try to make a program to calculate integrals. I want to read the equation from a textbox and i don't know how to store it. For example i write in the textbox : 3x^2+2x+1. How can i make some arrays to store every member of that equation and to solve it ?
You really should include code if you want people to help you. I have a suggestion but it really all depends. Are you only wanting to put the numbers in an array or all characters and symbols? Or are you wanting to put the entire equation as one entry in the array? I am not sure an array would be the best route to go for this sort of thing. But whatever.
Public Class Form1
Dim EqArray() As string
Public Sub Array_Entry()
Dim NewEntry as string = textbox1.text
EqArray.items.add(NewEntry)
msgbox(NewEntry & " has been added.")
End Sub
End Class

search for number in txt.file and get all results [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a text file containing a 30,000-line
I want to search for two numbers designated in the text file ...
And the results I get is a whole line .....
This is an example of the way the search and display the results ...
Please help me, because I need it very badly
An example of the text to be searched inside
Desired results
Something like the below could work. What it does is, loops through your file line at a time and uses an IF statement to test if it meets the requirements. Then once you find the line, return it or do what you want with it and then exit the for loop if found.
For Each line As String In File.ReadLines("file.txt")
If line.Contains("Here put the first number") AndAlso line.Contains("Here put the second number")
'you found the line, now return the line
Exit For 'Once you found the line exit the loop, as it will continue reading the file
End If
Next
Also this information could have found by googling how to read in a file. File.ReadLines This link can help you understand whats happening.

VBA deleting chart series [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My chart contains some extraneous series. These series all contain the word "series" in them (e.g., "Series1", "Series2") rather than descriptive names.
Can someone please provide a VBA procedure that executes this Pseudocode:
In chart 1 if any series name contains the word "series" delete it.
If not then do nothing
Sub DeleteSeriesWith_Series_InName()
Dim iSrs As Long
With ActiveChart
For iSrs = .SeriesCollection.Count To 1 Step -1
If InStr(LCase$(.SeriesCollection(iSrs).Name), "series") > 0 Then
.SeriesCollection(iSrs).Delete
End If
Next
End With
End Sub
Count series backwards, because deleting a series changes the series numbers of any series after it.