\n",
+ "\"
Well, Prince, so Genoa and Lucca are now just family estates of the\n",
+ "Buonapartes. But I warn you, if you don't tell me that this means war,\n",
+ "if you still try to defend the infamies and horrors perpetrated by\n",
+ "that Antichrist- I really believe he is Antichrist- I will have\n",
+ "nothing more to do with you and you are no longer my friend, no longer\n",
+ "my 'faithful slave,' as you call yourself! But how do you do? I see\n",
+ "I have frightened you- sit down and tell me all the news.\"\n",
+ "
\n",
+ "It was in July, 1805, and the speaker was the well-known
Anna\n",
+ "Pavlovna Scherer, maid of honor and favorite of the
Empress Marya\n",
+ "Fedorovna. With these words she greeted
Prince Vasili Kuragin, a man\n",
+ "of high rank and importance, who was the first to arrive at her\n",
+ "reception.
Anna Pavlovna had had a cough for some days. She was, as\n",
+ "she said, suffering from la grippe; grippe being then a new word in\n",
+ "
St. Petersburg, used only by the elite.\n",
+ "
\n",
+ "All her invitations without exception, written in French, and\n",
+ "delivered by a scarlet-liveried footman that morning, ran as follows:\n",
+ "
\n",
+ "\"
If you have nothing better to do, Count [or Prince], and if the\n",
+ "prospect of spending an evening with a poor invalid is not too\n",
+ "terrible, I shall be very charmed to see you tonight between 7 and 10-\n",
+ "Annette Scherer.\"\n",
+ "
\n",
+ "\"
Heavens! what a virulent attack!\" replied
the prince, not in the\n",
+ "least disconcerted by this reception. He had just entered, wearing\n",
+ "an embroidered court uniform, knee breeches, and shoes, and had\n",
+ "stars on his breast and a serene expression on his flat face. He spoke\n",
+ "in that refined French in which our grandfathers not only spoke but\n",
+ "thought, and with the gentle, patronizing intonation natural to a\n",
+ "man of importance who had grown old in society and at court. He went\n",
+ "up to
Anna Pavlovna, kissed her hand, presenting to her his bald,\n",
+ "scented, and shining head, and complacently seated himself on the\n",
+ "sofa.\n",
+ "
\n",
+ "\"
First of all, dear friend, tell me how you are. Set your friend's\n",
+ "mind at rest,\" said he without altering his tone, beneath the\n",
+ "politeness and affected sympathy of which indifference and even\n",
+ "irony could be discerned.\n",
+ "
\n",
+ "\"
Can one be well while suffering morally? Can one be calm in times\n",
+ "like these if one has any feeling?\" said
Anna Pavlovna. \"
You are\n",
+ "staying the whole evening, I hope?\"\n",
+ "
\n",
+ "\"
And the fete at the English ambassador's? Today is Wednesday. I\n",
+ "must put in an appearance there,\" said
the prince. \"
My daughter is\n",
+ "coming for me to take me there.\"\n",
+ "
\n",
+ "\"
I thought today's fete had been canceled. I confess all these\n",
+ "festivities and fireworks are becoming wearisome.\"\n",
+ "
\n",
+ "\"
If they had known that you wished it, the entertainment would\n",
+ "have been put off,\" said
the prince, who, like a wound-up clock, by\n",
+ "force of habit said things he did not even wish to be believed.\n",
+ "
\n",
+ "\"
Don't tease! Well, and what has been decided about Novosiltsev's\n",
+ "dispatch? You know everything.\"\n",
+ "
\n",
+ "\"
What can one say about it?\" replied
the prince in a cold,\n",
+ "listless tone. \"
What has been decided? They have decided that\n",
+ "Buonaparte has burnt his boats, and I believe that we are ready to\n",
+ "burn ours.\"\n",
+ "
\n",
+ "
Prince Vasili always spoke languidly, like an actor repeating a\n",
+ "stale part.
Anna Pavlovna Scherer on the contrary, despite her forty\n",
+ "years, overflowed with animation and impulsiveness. To be an\n",
+ "enthusiast had become her social vocation and, sometimes even when she\n",
+ "did not feel like it, she became enthusiastic in order not to\n",
+ "disappoint the expectations of those who knew her. The subdued smile\n",
+ "which, though it did not suit her faded features, always played\n",
+ "round her lips expressed, as in a spoiled child, a continual\n",
+ "consciousness of her charming defect, which she neither wished, nor\n",
+ "could, nor considered it necessary, to correct.\n",
+ "
\n",
+ "In the midst of a conversation on political matters
Anna Pavlovna\n",
+ "burst out:\n",
+ "
\n",
+ "\"
Oh, don't speak to me of Austria. Perhaps I don't understand\n",
+ "things, but Austria never has wished, and does not wish, for war.\n",
+ "She is betraying us! Russia alone must save Europe. Our gracious\n",
+ "sovereign recognizes his high vocation and will be true to it. That is\n",
+ "the one thing I have faith in! Our good and wonderful sovereign has to\n",
+ "perform the noblest role on earth, and he is so virtuous and noble\n",
+ "that God will not forsake him. He will fulfill his vocation and\n",
+ "crush the hydra of revolution, which has become more terrible than\n",
+ "ever in the person of this murderer and villain! We alone must\n",
+ "avenge the blood of the just one.... Whom, I ask you, can we rely\n",
+ "on?... England with her commercial spirit will not and cannot\n",
+ "understand the Emperor Alexander's loftiness of soul. She has\n",
+ "refused to evacuate Malta. She wanted to find, and still seeks, some\n",
+ "secret motive in our actions. What answer did Novosiltsev get? None.\n",
+ "The English have not understood and cannot understand the\n",
+ "self-abnegation of our Emperor who wants nothing for himself, but only\n",
+ "desires the good of mankind. And what have they promised? Nothing! And\n",
+ "what little they have promised they will not perform! Prussia has\n",
+ "always declared that Buonaparte is invincible, and that all Europe\n",
+ "is powerless before him.... And I don't believe a word that Hardenburg\n",
+ "says, or Haugwitz either. This famous Prussian neutrality is just a\n",
+ "trap. I have faith only in God and the lofty destiny of our adored\n",
+ "monarch. He will save Europe!\"\n",
+ "
\n",
+ "She suddenly paused, smiling at her own impetuosity.\n",
+ "
\n",
+ "\"
I think,\" said
the prince with a smile, \"
that if you had been\n",
+ "sent instead of our dear Wintzingerode you would have captured the\n",
+ "King of Prussia's consent by assault. You are so eloquent. Will you\n",
+ "give me a cup of tea?\"\n",
+ "
\n",
+ "\"
In a moment. A propos,\" she added, becoming calm again, \"
I am\n",
+ "expecting two very interesting men tonight, le Vicomte de Mortemart,\n",
+ "who is connected with the Montmorencys through the Rohans, one of\n",
+ "the best French families. He is one of the genuine emigres, the good\n",
+ "ones. And also the Abbe Morio. Do you know that profound thinker? He\n",
+ "has been received by the Emperor. Had you heard?\"\n",
+ "
\n",
+ "\"
I shall be delighted to meet them,\" said
the prince. \"
But tell me,\"\n",
+ "he added with studied carelessness as if it had only just occurred\n",
+ "to him, though the question he was about to ask was the chief motive\n",
+ "of his visit, \"
is it true that the Dowager Empress wants Baron Funke\n",
+ "to be appointed first secretary at Vienna? The baron by all accounts\n",
+ "is a poor creature.\"\n",
+ "
\n",
+ "
Prince Vasili wished to obtain this post for his son, but others\n",
+ "were trying through the
Dowager Empress Marya Fedorovna to secure it\n",
+ "for
the baron.\n",
+ "
\n",
+ "
Anna Pavlovna almost closed her eyes to indicate that neither she\n",
+ "nor anyone else had a right to criticize what
the Empress desired or\n",
+ "was pleased with.\n",
+ "
\n",
+ "\"
Baron Funke has been recommended to the Dowager Empress by her\n",
+ "sister,\" was all she said, in a dry and mournful tone.\n",
+ "
\n",
+ "As she named
the Empress,
Anna Pavlovna's face suddenly assumed an\n",
+ "expression of profound and sincere devotion and respect mingled with\n",
+ "sadness, and this occurred every time she mentioned her illustrious\n",
+ "patroness. She added that
Her Majesty had deigned to show
Baron\n",
+ "Funke, and again her face clouded over with sadness.\n",
+ "
\n",
+ "
The prince was silent and looked indifferent. But, with the\n",
+ "womanly and courtierlike quickness and tact habitual to her,
Anna\n",
+ "Pavlovna wished both to rebuke him (for daring to speak he had done of\n",
+ "a man recommended to
the Empress) and at the same time to console him,\n",
+ "so she said:\n",
+ "
\n",
+ "\"
Now about your family. Do you know that since your daughter came\n",
+ "out everyone has been enraptured by her? They say she is amazingly\n",
+ "beautiful.\"\n",
+ "
\n",
+ "
The prince bowed to signify his respect and gratitude.\n",
+ "
\n",
+ "\"
I often think,\" she continued after a short pause, drawing nearer\n",
+ "to the prince and smiling amiably at him as if to show that\n",
+ "political and social topics were ended and the time had come for\n",
+ "intimate conversation- \"
I often think how unfairly sometimes the\n",
+ "joys of life are distributed. Why has fate given you two such splendid\n",
+ "children? I don't speak of Anatole, your youngest. I don't like\n",
+ "him,\" she added in a tone admitting of no rejoinder and raising her\n",
+ "eyebrows. \"
Two such charming children. And really you appreciate\n",
+ "them less than anyone, and so you don't deserve to have them.\"\n",
+ "
\n",
+ "And she smiled her ecstatic smile.\n",
+ "
\n",
+ "\"
I can't help it,\" said
the prince. \"
Lavater would have said I\n",
+ "lack the bump of paternity.\"\n",
+ "
\n",
+ "\"
Don't joke; I mean to have a serious talk with you. Do you know I\n",
+ "am dissatisfied with your younger son? Between ourselves\" (and her\n",
+ "face assumed its melancholy expression), \"
he was mentioned at Her\n",
+ "Majesty's and you were pitied....\"\n",
+ "
\n",
+ "
The prince answered nothing, but she looked at him significantly,\n",
+ "awaiting a reply. He frowned.\n",
+ "
\n",
+ "\"
What would you have me do?\" he said at last. \"
You know I did all\n",
+ "a father could for their education, and they have both turned out\n",
+ "fools. Hippolyte is at least a quiet fool, but Anatole is an active\n",
+ "one. That is the only difference between them.\" He said this smiling\n",
+ "in a way more natural and animated than usual, so that the wrinkles\n",
+ "round his mouth very clearly revealed something unexpectedly coarse\n",
+ "and unpleasant.\n",
+ "
\n",
+ "\"
And why are children born to such men as you? If you were not a\n",
+ "father there would be nothing I could reproach you with,\" said
Anna\n",
+ "Pavlovna, looking up pensively.\n",
+ "
\n",
+ "\"
I am your faithful slave and to you alone I can confess that my\n",
+ "children are the bane of my life. It is the cross I have to bear. That\n",
+ "is how I explain it to myself. It can't be helped!\"\n",
+ "
\n",
+ "He said no more, but expressed his resignation to cruel fate by a\n",
+ "gesture.
Anna Pavlovna meditated.\n",
+ "
\n",
+ "\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "from urllib.request import urlopen\n",
+ "from bs4 import BeautifulSoup\n",
+ "html = urlopen('http://www.pythonscraping.com/pages/warandpeace.html')\n",
+ "bs = BeautifulSoup(html, 'html.parser')\n",
+ "print(bs)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from urllib.request import urlopen\n",
+ "from bs4 import BeautifulSoup\n",
+ "html = urlopen('http://www.pythonscraping.com/pages/warandpeace.html')\n",
+ "bs = BeautifulSoup(html, \"html.parser\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Well, Prince, so Genoa and Lucca are now just family estates of the\n",
+ "Buonapartes. But I warn you, if you don't tell me that this means war,\n",
+ "if you still try to defend the infamies and horrors perpetrated by\n",
+ "that Antichrist- I really believe he is Antichrist- I will have\n",
+ "nothing more to do with you and you are no longer my friend, no longer\n",
+ "my 'faithful slave,' as you call yourself! But how do you do? I see\n",
+ "I have frightened you- sit down and tell me all the news.\n",
+ "Anna\n",
+ "Pavlovna Scherer\n",
+ "Empress Marya\n",
+ "Fedorovna\n",
+ "Prince Vasili Kuragin\n",
+ "Anna Pavlovna\n",
+ "St. Petersburg\n",
+ "If you have nothing better to do, Count [or Prince], and if the\n",
+ "prospect of spending an evening with a poor invalid is not too\n",
+ "terrible, I shall be very charmed to see you tonight between 7 and 10-\n",
+ "Annette Scherer.\n",
+ "Heavens! what a virulent attack!\n",
+ "the prince\n",
+ "Anna Pavlovna\n",
+ "First of all, dear friend, tell me how you are. Set your friend's\n",
+ "mind at rest,\n",
+ "Can one be well while suffering morally? Can one be calm in times\n",
+ "like these if one has any feeling?\n",
+ "Anna Pavlovna\n",
+ "You are\n",
+ "staying the whole evening, I hope?\n",
+ "And the fete at the English ambassador's? Today is Wednesday. I\n",
+ "must put in an appearance there,\n",
+ "the prince\n",
+ "My daughter is\n",
+ "coming for me to take me there.\n",
+ "I thought today's fete had been canceled. I confess all these\n",
+ "festivities and fireworks are becoming wearisome.\n",
+ "If they had known that you wished it, the entertainment would\n",
+ "have been put off,\n",
+ "the prince\n",
+ "Don't tease! Well, and what has been decided about Novosiltsev's\n",
+ "dispatch? You know everything.\n",
+ "What can one say about it?\n",
+ "the prince\n",
+ "What has been decided? They have decided that\n",
+ "Buonaparte has burnt his boats, and I believe that we are ready to\n",
+ "burn ours.\n",
+ "Prince Vasili\n",
+ "Anna Pavlovna\n",
+ "Anna Pavlovna\n",
+ "Oh, don't speak to me of Austria. Perhaps I don't understand\n",
+ "things, but Austria never has wished, and does not wish, for war.\n",
+ "She is betraying us! Russia alone must save Europe. Our gracious\n",
+ "sovereign recognizes his high vocation and will be true to it. That is\n",
+ "the one thing I have faith in! Our good and wonderful sovereign has to\n",
+ "perform the noblest role on earth, and he is so virtuous and noble\n",
+ "that God will not forsake him. He will fulfill his vocation and\n",
+ "crush the hydra of revolution, which has become more terrible than\n",
+ "ever in the person of this murderer and villain! We alone must\n",
+ "avenge the blood of the just one.... Whom, I ask you, can we rely\n",
+ "on?... England with her commercial spirit will not and cannot\n",
+ "understand the Emperor Alexander's loftiness of soul. She has\n",
+ "refused to evacuate Malta. She wanted to find, and still seeks, some\n",
+ "secret motive in our actions. What answer did Novosiltsev get? None.\n",
+ "The English have not understood and cannot understand the\n",
+ "self-abnegation of our Emperor who wants nothing for himself, but only\n",
+ "desires the good of mankind. And what have they promised? Nothing! And\n",
+ "what little they have promised they will not perform! Prussia has\n",
+ "always declared that Buonaparte is invincible, and that all Europe\n",
+ "is powerless before him.... And I don't believe a word that Hardenburg\n",
+ "says, or Haugwitz either. This famous Prussian neutrality is just a\n",
+ "trap. I have faith only in God and the lofty destiny of our adored\n",
+ "monarch. He will save Europe!\n",
+ "I think,\n",
+ "the prince\n",
+ "that if you had been\n",
+ "sent instead of our dear Wintzingerode you would have captured the\n",
+ "King of Prussia's consent by assault. You are so eloquent. Will you\n",
+ "give me a cup of tea?\n",
+ "Wintzingerode\n",
+ "King of Prussia\n",
+ "In a moment. A propos,\n",
+ "I am\n",
+ "expecting two very interesting men tonight, le Vicomte de Mortemart,\n",
+ "who is connected with the Montmorencys through the Rohans, one of\n",
+ "the best French families. He is one of the genuine emigres, the good\n",
+ "ones. And also the Abbe Morio. Do you know that profound thinker? He\n",
+ "has been received by the Emperor. Had you heard?\n",
+ "le Vicomte de Mortemart\n",
+ "Montmorencys\n",
+ "Rohans\n",
+ "Abbe Morio\n",
+ "the Emperor\n",
+ "I shall be delighted to meet them,\n",
+ "the prince\n",
+ "But tell me,\n",
+ "is it true that the Dowager Empress wants Baron Funke\n",
+ "to be appointed first secretary at Vienna? The baron by all accounts\n",
+ "is a poor creature.\n",
+ "Prince Vasili\n",
+ "Dowager Empress Marya Fedorovna\n",
+ "the baron\n",
+ "Anna Pavlovna\n",
+ "the Empress\n",
+ "Baron Funke has been recommended to the Dowager Empress by her\n",
+ "sister,\n",
+ "the Empress\n",
+ "Anna Pavlovna's\n",
+ "Her Majesty\n",
+ "Baron\n",
+ "Funke\n",
+ "The prince\n",
+ "Anna\n",
+ "Pavlovna\n",
+ "the Empress\n",
+ "Now about your family. Do you know that since your daughter came\n",
+ "out everyone has been enraptured by her? They say she is amazingly\n",
+ "beautiful.\n",
+ "The prince\n",
+ "I often think,\n",
+ "I often think how unfairly sometimes the\n",
+ "joys of life are distributed. Why has fate given you two such splendid\n",
+ "children? I don't speak of Anatole, your youngest. I don't like\n",
+ "him,\n",
+ "Anatole\n",
+ "Two such charming children. And really you appreciate\n",
+ "them less than anyone, and so you don't deserve to have them.\n",
+ "I can't help it,\n",
+ "the prince\n",
+ "Lavater would have said I\n",
+ "lack the bump of paternity.\n",
+ "Don't joke; I mean to have a serious talk with you. Do you know I\n",
+ "am dissatisfied with your younger son? Between ourselves\n",
+ "he was mentioned at Her\n",
+ "Majesty's and you were pitied....\n",
+ "The prince\n",
+ "What would you have me do?\n",
+ "You know I did all\n",
+ "a father could for their education, and they have both turned out\n",
+ "fools. Hippolyte is at least a quiet fool, but Anatole is an active\n",
+ "one. That is the only difference between them.\n",
+ "And why are children born to such men as you? If you were not a\n",
+ "father there would be nothing I could reproach you with,\n",
+ "Anna\n",
+ "Pavlovna\n",
+ "I am your faithful slave and to you alone I can confess that my\n",
+ "children are the bane of my life. It is the cross I have to bear. That\n",
+ "is how I explain it to myself. It can't be helped!\n",
+ "Anna Pavlovna\n"
+ ]
+ }
+ ],
+ "source": [
+ "#.find_all('span', {'class':{'green', 'red'}})\n",
+ "nameList = bs.findAll('span', {'class': ['green', 'red']})\n",
+ "for name in nameList:\n",
+ " print(name.get_text())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Anna\n",
+ "Pavlovna Scherer\n",
+ "Empress Marya\n",
+ "Fedorovna\n",
+ "Prince Vasili Kuragin\n",
+ "Anna Pavlovna\n",
+ "St. Petersburg\n",
+ "the prince\n",
+ "Anna Pavlovna\n",
+ "Anna Pavlovna\n",
+ "the prince\n",
+ "the prince\n",
+ "the prince\n",
+ "Prince Vasili\n",
+ "Anna Pavlovna\n",
+ "Anna Pavlovna\n",
+ "the prince\n",
+ "Wintzingerode\n",
+ "King of Prussia\n",
+ "le Vicomte de Mortemart\n",
+ "Montmorencys\n",
+ "Rohans\n",
+ "Abbe Morio\n",
+ "the Emperor\n",
+ "the prince\n",
+ "Prince Vasili\n",
+ "Dowager Empress Marya Fedorovna\n",
+ "the baron\n",
+ "Anna Pavlovna\n",
+ "the Empress\n",
+ "the Empress\n",
+ "Anna Pavlovna's\n",
+ "Her Majesty\n",
+ "Baron\n",
+ "Funke\n",
+ "The prince\n",
+ "Anna\n",
+ "Pavlovna\n",
+ "the Empress\n",
+ "The prince\n",
+ "Anatole\n",
+ "the prince\n",
+ "The prince\n",
+ "Anna\n",
+ "Pavlovna\n",
+ "Anna Pavlovna\n"
+ ]
+ }
+ ],
+ "source": [
+ "nameList = bs.findAll('span', {'class': 'green'})\n",
+ "for name in nameList:\n",
+ " print(name.get_text())"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[