الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كود جالب الأخبار

مغلق
بدأه hrfr في 28 مارس 2005 · 1 رد · 663 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

مع التحية للجميع هذ كامل الشفرة لجلب الأخبار من البي بي سي ولكن اريد عندما انقر بالفأرة على العنوان انتقل الى الصفحة الخاصة بالعنوان فكيف ذلك

Imports System.Net

Imports System.Text

Public Class news

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Protected WithEvents div_news As System.Web.UI.HtmlControls.HtmlGenericControl

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim http_request As HttpWebRequest

Dim http_response As HttpWebResponse

Dim web_request As WebRequest

Dim the_content As String

Dim the_encoding As Encoding

http_request = web_request.Create("http://news.bbc.co.uk/low/arabic/middle_east_news/default.stm")

http_request.Timeout = 10000

http_request.UserAgent = "any_thing"

http_response = http_request.GetResponse

the_encoding = Encoding.GetEncoding(1256)

Dim stream_reader As New System.IO.StreamReader(http_response.GetResponseStream, the_encoding)

the_content = stream_reader.ReadToEnd

http_response.Close()

stream_reader.Close()

GetNewsList(the_content)

End Sub

Sub GetNewsList(ByVal page_content As String)

Dim body As String

Dim news(8) As String

Dim dummy As String

Dim position As Long

Dim str_letter As String

Dim news_count As Int16

Dim i As Long

body = Trim(page_content)

If body <> "" Then

dummy = InStr(body, "startcontent")

body = Mid(body, dummy + 1)

dummy = InStr(body, "startcontent")

body = Mid(body, dummy)

Do

dummy = InStr(body, "<b>")

If dummy = 0 Then Exit Do

body = Mid(body, dummy + 1)

position = 3

If position > Len(body) Then Exit Do

str_letter = Mid(body, position, 1)

news_count = news_count + 1

If news_count > 8 Then Exit Do

Do While str_letter <> "<"

position = position + 1

If position > Len(body) Then Exit Do

str_letter = Mid(body, position, 1)

If str_letter = "<" Then Exit Do

If str_letter <> Chr(13) And str_letter <> Chr(9) And str_letter <> Chr(10) Then

news(news_count) = news(news_count) & str_letter

End If

Loop

Loop

div_news.InnerHtml = "<marquee direction='right'>"

For i = 1 To 8

news(i) = Trim(news(i))

news(i) = Replace(news(i), """, Chr(34))

If i <> 4 Then

div_news.InnerHtml = div_news.InnerHtml & " | " & (news(i))

End If

Next i

div_news.InnerHtml = div_news.InnerHtml & "</marquee>"

End If

End Sub

End Class

#2
Imports System.Net
Imports System.Text
Public Class news
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents div_news As System.Web.UI.HtmlControls.HtmlGenericControl

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim http_request As HttpWebRequest
Dim http_response As HttpWebResponse
Dim web_request As WebRequest
Dim the_content As String
Dim the_encoding As Encoding
http_request = web_request.Create("http://news.bbc.co.uk/low/arabic/middle_east_news/default.stm")
http_request.Timeout = 10000
http_request.UserAgent = "any_thing"



http_response = http_request.GetResponse
the_encoding = Encoding.GetEncoding(1256)

Dim stream_reader As New System.IO.StreamReader(http_response.GetResponseStream, the_encoding)
the_content = stream_reader.ReadToEnd



http_response.Close()
stream_reader.Close()

GetNewsList(the_content)
End Sub
Sub GetNewsList(ByVal page_content As String)

Dim body As String
Dim news(8) As String
Dim dummy As String
Dim position As Long
Dim str_letter As String
Dim news_count As Int16
Dim i As Long
body = Trim(page_content)

If body <> "" Then
dummy = InStr(body, "startcontent")
body = Mid(body, dummy + 1)
dummy = InStr(body, "startcontent")
body = Mid(body, dummy)
Do
dummy = InStr(body, "<b>")
If dummy = 0 Then Exit Do
body = Mid(body, dummy + 1)
position = 3
If position > Len(body) Then Exit Do
str_letter = Mid(body, position, 1)
news_count = news_count + 1
If news_count > 8 Then Exit Do
Do While str_letter <> "<"
position = position + 1
If position > Len(body) Then Exit Do
str_letter = Mid(body, position, 1)
If str_letter = "<" Then Exit Do
If str_letter <> Chr(13) And str_letter <> Chr(9) And str_letter <> Chr(10) Then
news(news_count) = news(news_count) & str_letter
End If
Loop
Loop

div_news.InnerHtml = "<marquee direction='right'>"
For i = 1 To 8
news(i) = Trim(news(i))
news(i) = Replace(news(i), """, Chr(34))
If i <> 4 Then
div_news.InnerHtml = div_news.InnerHtml & " | " & (news(i))
End If
Next i
div_news.InnerHtml = div_news.InnerHtml & "</marquee>"
End If


End Sub


End Class

اخي اليس هذا افضل

هذا الموضوع مغلق.

مواضيع مشابهة