I want to pull and display the twitter username of various accounts that I specify via the ID. I figured I could do this, in part, with wget.
echo what id would you like to search
read ID
wget https://twitter.com/intent/user?user_id=$ID > ~/temp/$ID
This is really as far as I got as I cant figure out how to pull the data from it. I have tried this;
read ID
source ~/temp/$ID
echo $value
To echo anything that was labeled as “value” (the username is labeled as “value” several times).
Examples:
Stack Overflow’s Twitter account is @stackoverflow, and their twitter id is: 128700677 So I can run
wget https://twitter.com/intent/user?user_id=128700677
and the document will be a nice 248 line long HTML document, you can try it and see. So basically, is there a way to have the script either go through and find the most common value=”” or just go to/display <title>Stack Overflow (@StackOverflow) on Twitter</title>
without the <title></title>
and on Twitter
PS: Would this count as bootstrapping?
EDIT—————————–
This needs to be able to work with bash because I already have a system set up in bash. This will just help confirm @s
2
Answers
As that-other-guy said, it would be better to use twitter API to find that out. However, you can try and push your method a little bit further, like
to filter out strings like
href='/intent/user?screen_name=StackOverflow'
and extract what’s afterscreen_name=
part in the first string.P.S. I didn’t notice a lot of
value=
in the html, to be honest, and sourcing something like html in your script is not the best thing to do, as you may get something destructive executing this way.screen_name
could be fetched with:nickname
could be fetched with:title
could be fetched with:The use of the REST API sounds a better idea.