I am new to Wolfram and i would like to extract a few words from a website based on locating a key string.
Specifically, i am trying to access the website: https://www.sec.gov/Archives/edgar/data/2178/000000217818000009/a2017form10-k.htm and locate the string "Address of Principal Executive Offices" and then scrape the address located right before the string "Address of Principal Executive offices".
I have run the following codes:
data = Import["https://www.sec.gov/Archives/edgar/data/2178/000000217818000009/a2017form10-k.htm", "Plaintext"]
this line above imports the link above.
keystring = StringPosition[data, {"Address of Principal Executive Offices"}]
This code above locates the string position at {{746, 783}}
How do I extract 10 words located right before the initial position of {{746}} so I could scrape the actual address and save that to Excel?
May i also ask that if i have a batch of websites saved on a .csv file, how i would apply "StringCases[plainText, "(I.R.S. Employer Identification No.)\n\n" ~~ a___ ~~ "\n\n(Address of Principal Executive Offices)" :> a];" to all of them?
For now, i have the following codes:
dataset = Import[FileNameJoin[{NotebookDirectory[], "linksto10k11.csv"}],"Dataset", HeaderLines -> 1];
dataWithProxyStatementURL = dataset[All, 13];
Above codes import the csv file i have with links to 10-K websites. Then, i run the following code to hopefully retrieve the actual address as above.
processProxyURL[proxyURL_] := Module[{plainText, address},plainText = Import[proxyURL, "Plaintext"];
address = StringCases[plainText,"(I.R.S. Employer Identification No.)\n\n" ~~ a___ ~~ "\n\n(Address of Principal Executive Offices)" :> a]; <|"Address" -> address|>];
Allrangeoutput =dataset[All, <|#,"All Range" -> processProxyURL[#["proxyStatementURL"]]|> &];
However, the above codes do not generate the actual address but only generate blanks - may i ask how i could update my codes accordingly so that i could retrieve the actual address?
Thank you so much!