我有一個看起來像這樣的原始文本:
我們是 AMS。我們是一家全球性的勞動力整體解決方案公司;我們通過建立、重塑和優化員工隊伍,使組織能夠在不斷變化的時代蓬勃發展。我們的臨時勞動力解決方案 (CWS) 是我們的服務之一;我們作為客戶招聘團隊的延伸,提供專業的臨時和臨時資源。
我們目前正在與我們的客戶皇家倫敦合作。
Royal London 是一家與眾不同的金融服務公司。作為英國最大的共同人壽、養老金和投資公司,我們為會員所有,并為他們的利益而非股東利益而作業。我們發展迅速,被公認為英國最受好評的作業場所之一。
如今,皇家倫敦管理著超過 1140 億英鎊的資金,在英國和愛爾蘭的六個辦事處擁有約 3,500 名員工。我們努力成為我們專業市場的專家,建立一個值得信賴的品牌——我們的團隊為此獲得了很多獎項。無論你有興趣加入什么團隊,扮演什么角色;我們將幫助您有所作為。
我們正在為倫敦的 6 個月合同尋找業務分析師。
角色的目的:
您將與內部資料小組合作,研究業務中的新功能和相關報告。部分專案將涉及系統升級
作為業務分析師,您將負責:
查看資料集、提取資訊并能夠查看 SQL 腳本、撰寫報告序列、分析資料。能夠理解和交付資料,提出問題和挑戰要求,了解資料旅程/映射檔案。
我們向您尋求的技能、屬性和能力包括:
- 強大的口頭和書面溝通
- Scrum 團隊內部、與其他 BA 以及直接與業務用戶的強大團隊合作
- 豐富的資產管理經驗
- 資產經理使用的關鍵資料集的作業知識
- 擁有主資料管理工具的經驗,最好是 IHS Markit EDM
- 敏捷的作業經驗
- 能夠撰寫用戶故事以詳細說明開發團隊和* QA 團隊將使用的需求
- 強大的 SQL 技能,最好使用 Microsoft SQL Server
- 管理資料介面映射檔案的經驗
- 熟悉資料建模概念
- 基于ETL和資料倉庫的專案經驗優勢
- 技術(開發)背景優勢
- 有資產管理背景。
- Thinkfolio 和 Murex 將是理想的,EDM 平臺知識將是可取的。此客戶將僅接受通過參與模式操作的員工。
如果您有興趣申請此職位并符合上述標準,請單擊鏈接申請并立即與我們的一位采購專家交談。
AMS 是一家招聘流程外包公司,在提供其某些服務時,可能會被視為作為職業介紹所或職業企業運營
我已經使用下面的方法從原始 html 中使用漂亮的湯根據子標題拆分和提取文本。基本上,目標是:
- 用粗體文本分隔 html 提取。
- 從這個粗體文本串列中,提取那些既粗體又帶有“:”的文本以表示它是合法的子標題
- 然后從粗體文本串列中找出第一個和最后一個合法子標題的位置。如果在最后一個子標題的文本下方還有其他粗體文本缺少“:”,這將有助于拆分文本。
- 根據最后一個子標題確實是粗體文本串列中的最后一個元素的條件進行拆分,如果不是,則進一步拆分文本以將子標題的文本與其他文本分開。
下面的代碼演示了這一點:
from fake_useragent import UserAgent
import requests
def headers():
ua = UserAgent()
chrome_header = ua.chrome
headers = {'User-Agent': chrome_header}
return headers
headers = headers()
r5 = requests.get("https://www.reed.co.uk/jobs/business-analyst/46819093?source=searchResults&filter=/jobs/business-jobs-in-london?agency=True&direct=True", headers=headers, timeout=20)
soup_description = BS(r5.text, 'html.parser')
j_description = soup_description.find('span', {'itemprop':'description'})
j_description_subtitles = [j.text for j in j_description.find_all('strong')]
sub_titles_in_description = [el for el in j_description_subtitles if ":" in el]
total_length_of_sub_titles = len(sub_titles_in_description)
total_length_of_strong_tags = len(j_description_subtitles)
Position_of_first_sub_title = j_description_subtitles.index(sub_titles_in_description[0])
Position_of_last_sub_title = j_description_subtitles.index(sub_titles_in_description[-1])
# If the position of the last subtitle text does not equal the total number of strong tags, then split the final output by the next indexed position in the list.
if Position_of_last_sub_title != total_length_of_strong_tags:
text_after_sub_t= re.split(f'{sub_titles_in_description[0]}|{sub_titles_in_description[1]}|{sub_titles_in_description[-1]}| {j_description_subtitles[Position_of_last_sub_title 1]}',j_description.text)[1:Position_of_last_sub_title]
else:
text_after_sub_t= re.split(f'{sub_titles_in_description[0]}|{sub_titles_in_description[1]}|{sub_titles_in_description[-1]}',j_description.text)[1:]
final_dict_with_sub_t_n_prec_txt= {
sub_titles_in_description[0]: text_after_sub_t[0],
sub_titles_in_description[1]: text_after_sub_t[1],
sub_titles_in_description[2]: text_after_sub_t[2]
}
問題是基于子標題的文本拆分。它太手動了,并且嘗試了其他方法無濟于事。我將如何使這部分動態化,因為在未來的文本中,字幕的數量會有所不同。
uj5u.com熱心網友回復:
css selectors您可以通過用于選擇元素來簡化或使其更通用,例如p:has(strong:-soup-contains(":"))選擇所有<p>具有. 獲取附加資訊使用:<strong>:find_next_sibling()
dict((e.text,e.find_next_sibling().get_text('|',strip=True)) for e in soup.select('[itemprop="description"] p:has(strong:-soup-contains(":"))'))
注意: 作為分隔符添加到,因此在這種情況下,您可以稍后拆分串列元素。您也可以用空格替換它|get_text()get_text(' ',strip=True)
例子
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0'}
r = requests.get("https://www.reed.co.uk/jobs/business-analyst/46819093?source=searchResults&filter=/jobs/business-jobs-in-london?agency=True&direct=True", headers=headers, timeout=20)
soup = BeautifulSoup(r.text, 'html.parser')
data = dict((e.text,e.find_next_sibling().get_text('|',strip=True)) for e in soup.select('[itemprop="description"] p:has(strong:-soup-contains(":"))'))
print(data)
輸出
{'Purpose of the Role:': 'You will be working with the internal data squad looking at new functionality within the business and associated reporting. Part of project will involve system upgrades',
'As the Business Analyst, you will be responsible for:': 'Looking at data sets, extracting the information and be able to look at SQL scripts, write report sequences, analyse data. Be able to understand and deliver data, ask questions and challenge requirements, understand the data journey/mapping documents.',
'The skills, attributes and capabilities we are seeking from you include:': 'Strong communication both verbal and written|Strong teamworking within the scrum team and with other BAs and directly with business users|Significant asset management experience|Working knowledge of the key data sets that are used by an asset manager|Experience of Master Data Management tools, ideally IHS Markit EDM|Agile working experience|Ability to write user stories to detail the requirements that both the development team and the QA team will use|Strong SQL skills, ideally using Microsoft SQL Server|Experience of managing data interface mapping documentation|Familiarity with data modelling concepts|Project experience based on ETL and Data Warehousing advantageous|Technical (development) background advantageous|Have an asset management background.|Thinkfolio and Murex would be ideal, EDM platform knowledge would be desirable.'}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/475456.html
上一篇:strlen默認為“40”?
下一篇:字串串列存在于字典鍵串列中?
